Live data from Hacker News

C# 8: Switch expressions

alexatnet.com

1–10 of 124 posts

Re: C# 8: Switch expressions

#2
This might be better titled "C# 8: switch expressions" (edit: it was previously "statement", as the author's post is titled).

Or actually, to bait a few more hn clicks (and provide a fuller description): "Pattern matching in C# 8 with switch expressions"

Re: C# 8: Switch expressions

#3
post #2

This might be better titled "C# 8: switch expressions" (edit: it was previously "statement", as the author's post is titled). Or actually, to bait a few more hn clicks (and provide a fuller description): "Pattern matching in C# 8 with switch expressions"

This might be better titled "changing things for the sake of changing things and appealing to the programming language geeks".

The new syntax is not intuitive, not more readable, just a bit more terse.

Re: C# 8: Switch expressions

#4
post #2

This might be better titled "C# 8: switch expressions" (edit: it was previously "statement", as the author's post is titled). Or actually, to bait a few more hn clicks (and provide a fuller description): "Pattern matching in C# 8 with switch expressions"

Agreed. I was wondering what they could have possibly changed in ye olde switch statements we’ve all been using for decades.

Edit: ye, iOS, ye!

Re: C# 8: Switch expressions

#5
To me, all these IIFE’s make a good case for adding a block-as-expression construct. Either take from Scala, where every block evaluates to the last expression executed in that block (and every statement is an expression); or maybe introduce some new syntax (‘do { .... }’ maybe?) if the prior would be a breaking change.

Re: C# 8: Switch expressions

#6
post #2

This might be better titled "C# 8: switch expressions" (edit: it was previously "statement", as the author's post is titled). Or actually, to bait a few more hn clicks (and provide a fuller description): "Pattern matching in C# 8 with switch expressions"

This might be better titled "changing things for the sake of changing things and appealing to the programming language geeks". The new syntax is not intuitive, not more readable, just a bit more terse.

Actually, I think it is rather intuitive and readable - but then again I programmed in lisp for years.

Re: C# 8: Switch expressions

#7

    // now you kind of enforced to
    // handle all values, otherwise
    // it will not compile
I fail to see how it will not compile if all values are not handled. C# switch is not traditional pattern matching, because you don't get compile time feedback.

Claiming that is does is disingenuous.

Re: C# 8: Switch expressions

#10
post #2

This might be better titled "C# 8: switch expressions" (edit: it was previously "statement", as the author's post is titled). Or actually, to bait a few more hn clicks (and provide a fuller description): "Pattern matching in C# 8 with switch expressions"

This might be better titled "changing things for the sake of changing things and appealing to the programming language geeks". The new syntax is not intuitive, not more readable, just a bit more terse.

This actually seems to be somewhat of a trend in C# as of late. Ever since they introduced lambdas, really.

While I use them every day, my favorite is still “replacing” String.Format with string literals. Shorter, sure, but less intuitive particularly for people coming from another language. You can do roughly the same thing in PHP with backticks, but most people avoid them for the same reasons.

I’m not sure how I feel about the trend as a whole. As long as I can continue using the old methods as well I suppose I don’t have much room to complain, but sometimes it does feel like we’re just changing for the sake of change and that’s usually a bad indicator.

Post reply on HN