-
-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
don't use exceptions to implement ismatch
and trymatch
#81
Comments
Yeah this has always been a performance issue. I think we need a little Rust-style |
Matching is essentially interpreted in MacroTools, right? I wonder how hard it would be to directly macroexpand patterns like |
Right, the core matching machinery is a function of both a template and an expression to match. We could do something smarter there, but it essentially means having two separate implementations of matching, and the performance benefit will not likely be that great. Really it's just the use of throw/catch that's adding the extra order of magnitude hit here. |
Why? If we had a compiled version, we could drop the interpreted one. Are you aware of any code that modifies the pattern and calls
I wonder about that. MacroTools is pretty ubiquitous these days. |
Perhaps. At the very least it's part of the API now (you can also splice runtime expressions into the pattern). But that might be infrequently-used enough that we can just get rid of it. I could see us getting something like 2x better with a compiled version, especially on simple cases like that one. Once you get to slurping and such though, there's always going to be quite a lot of dynamic dispatch, backtracking etc. and it's not that likely to have a noticeable impact of precompilation. I'm happy to be proven wrong though. We could always have a very simple compiler that bails out to the interpreter, and then gradually expand that and remove the current implementation as we go along – just needs someone willing to hack on it. |
This is causing JuliaLang/julia#28221. At least for APIs that return a result instead of exposing
MatchError
, the package should use return values instead of exceptions.The text was updated successfully, but these errors were encountered: