Closed sjoelund closed 5 years ago
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: https://github.com/sjoelund/MetaModelica.jl/blob/master/src/matchcontinue.jl
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!
Are you willing to assign the copyright to RelationalAI?
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.