-
Notifications
You must be signed in to change notification settings - Fork 6
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
Named matching of struct patterns using keyword arguments #3
Comments
Just to confirm, this seems like a useful feature to me and also feasible to implement in the current macro implementation of Rematch. |
Yes, it's possible and I also implemented it along with some features that probably shouldn't go into this package. I'm planning to automatically translate code in the MetaModelica language to Julia and introduced the matchcontinue construct (try next pattern on exception) and needed syntax for immutable lists. The code is at: There is some concern taken to optimize away assertions at compile-time although Julia couldn't quite remove all of them. I didn't have time to fully finish my work before the semester started and I got swamped with teaching. |
@sjoelund I've picked up this task and would like to incorporate your solution. Are you willing to assign the copyright to RelationalAI? Thanks! |
I hereby give you a license to incorporate the code in question as you please, including removing the OSMC copyright notice and making the derived work the copyright of RelationalAI. |
Thanks @sjoelund ! |
I would like to perform matching based on the name of a field (because my structs have a very long list of field names and matching the correct name+pattern in much less error-prone especially if a field is added or removed from a large struct). Consider a small example below:
I believe this should be possible with something like
getfield(a, :b) == 2
at runtime; possibly with a check to avoid errors.The text was updated successfully, but these errors were encountered: