I would appreciate your thoughts about the pattern matching. I’m having hard time to “get it right”. I’ve looked at many other implementations (listed at the “UPM-Design” link above) and all of them feel “not 100%”. Unfortunately, right now, I am failing to come up with my own design that would feel “100%”. Biggest next obstacle is syntax (smaller) and semantics (bigger) of capturing values.
Problems:
NGS does not have a reference type and I’m not fond introducing one just for patterns to be able to return values.
A syntax (example @a) for creating a function which would set a variable (F(val) a=val) would introduce additional problem - to which scope to add the a variable. According to language rules, it would be set inside the F..., which is not useful at all. Maybe in this case it should be “one above F”?
Capturing all the values and returning them is a bit verbose, “direct” mention of a variable name is more expressive.
Does ability to pass a pattern as value contradicts the ability to capture directly into variables?
I’ve probably missed some information, feel free to ask.
Among other things, this release contains work on pattern matching.
Release notes - https://github.com/ngs-lang/ngs/releases/tag/v0.2.11
More about pattern matching design in NGS - https://github.com/ngs-lang/ngs/wiki/UPM-Design
I would appreciate your thoughts about the pattern matching. I’m having hard time to “get it right”. I’ve looked at many other implementations (listed at the “UPM-Design” link above) and all of them feel “not 100%”. Unfortunately, right now, I am failing to come up with my own design that would feel “100%”. Biggest next obstacle is syntax (smaller) and semantics (bigger) of capturing values.
Problems:
@a
) for creating a function which would set a variable (F(val) a=val
) would introduce additional problem - to which scope to add thea
variable. According to language rules, it would be set inside theF...
, which is not useful at all. Maybe in this case it should be “one above F”?I’ve probably missed some information, feel free to ask.