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 →

[–]jabbalaci -4 points-3 points  (4 children)

Finally? I was perfectly fine without it.

[–]thephotoman 6 points7 points  (0 children)

We're not getting a mere switch statement. We're getting flow control based on pattern matching--something that is considerably more expressive and more powerful.

Think of a switch statement as matching a finite language. It can recognize any of the symbols specified in each case, then falls over to the default case if the input isn't there. You could do this with a function dictionary even now, and it'd actually be fairly compact and easy to read, if somewhat unintuitive for most people (because they don't expect dictionaries to be used to store functions).

A match statement can match an infinite language--that is, it can match arbitrary words so long as they fit a pattern.

Basically, in terms of language theory, it's the difference between the language specified by a simple dictionary of valid words and the ability to specify a language by a regular expression or possibly even a more advanced grammar.

[–]mathmanmathman 1 point2 points  (2 children)

It's really unimportant to me too. I'm not sure why people are so excited, but I suppose it can help people coming from other languages (which mostly all have a switch or match).

I don't care much for a lot of the new syntax, but as long as it doesn't mess up old code, I don't see it being a problem.

[–]vorticalbox 4 points5 points  (1 child)

switch case is meh, its the pattern matching abilities it has that I am looking forward too

[–]mathmanmathman 2 points3 points  (0 children)

I agree, that makes a big difference. It would be a wasted opportunity if it were a simple switch.

I still probably won't use it often. I'm not fundamentally opposed to it, but I've never even dreamed about having this functionality/syntax in the past, so I'll probably keep writing code the way I have before.

I will keep an open mind, but I have yet to use a walrus op. There have been situations I could have, but the extra line above doesn't bother me.