Pattern Matching in Boo
Looks like it is a good thing that I picked that Erlang book, Boo just got Pattern Matching, I am looking at the code, and but for the grace of Erlang, I would be completely lost.
Looks like it is a good thing that I picked that Erlang book, Boo just got Pattern Matching, I am looking at the code, and but for the grace of Erlang, I would be completely lost.
And 4 more posts are pending...
There are posts all the way to Feb 17, 2025
Comments
Nice! It would be really cool if return could be put on the left hand side of the match statement, which would mean match would have to evaluate the selected value.
return match e:
etc.
Nice, but I can't think of a use case for it...
Check the examples, this is a very nice way of handling selections.
As always with new bamboo-driven Boo features, I get the general "this is sweeet" feeling, but I can't really understand what's being done. I see there's some kind of pattern-matching akin to Prolog's unification (and, from what I see, somewhat like Erlang which I don't know), which is cool, but I can't understand what they are doing in there, even after having read the code. Since you've already dove into the (reflectored) code, maybe you could explain what goes on in there?
Basically, think of it like case on steroids.
With the exception that you can do stuff like Foo: foo and if there is a match, then foo = expr
The idea is to express selects very clearly.
Comment preview