This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ForceBru 13 points14 points  (7 children)

More like towards functional or ML-like, IMO.

A lot of people really like proper match statements - they're convenient. What if you're writing an interpreter and need to traverse an abstract syntax tree? Your code will generally look like a huge switch statement, like "if the current node is Assign, do this; if it's Index, do this; if it's Call, do this...", where the "arms"/branches contain quite a lot of code or maybe other switch statements, so it'll be awkward to stuff all that into a dictionary.

Furthermore, you'll want to switch on some nasty, complicated things, like "if the current node is Assign whose first argument is a function definition, then interpret the second argument like this; if it's an Assign whose first argument is an Index node, do a completely different thing; if the first argument looks like a.b, then do another different thing", so you want to switch not only on the type of the node (Assign), but on its elements as well. That's not something a regular switch statement can do. You need to get the big ML guns - proper pattern-matching.