Ayende @ Rahien

Unnatural acts on source code

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.

Comments

Duncan Godwin
10/17/2007 12:37 AM by
Duncan Godwin

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.

Markus Zywitza
10/17/2007 06:59 AM by
Markus Zywitza

Nice, but I can't think of a use case for it...

Ayende Rahien
10/17/2007 07:05 AM by
Ayende Rahien

Check the examples, this is a very nice way of handling selections.

Avish
10/17/2007 05:17 PM by
Avish

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?

Ayende Rahien
10/17/2007 05:22 PM by
Ayende Rahien

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.

Comments have been closed on this topic.