docs icon indicating copy to clipboard operation
docs copied to clipboard

switch default to _ ? So disturbing.

Open obewan opened this issue 7 years ago • 3 comments

Since switch exists, we always use the "default" keywords for default case. Switching "default" to _ is very disturbing, specially when still using the "switch" keywords. In C, default is "default", since always, in C++ default is "default", in Java default is... "default" (amazing), in C# 1 to 7 too, same in Javascript, Php, Go... There is some languages that doesn't use 'default' keywords, but it is not a majority (SQL, Haskell, Erlang, Ruby, or Python that even doesn't have a switch (no comments)). So using _ will break the C of C#, it will be so disturbing that some switch will use 'default', some other will use _, in the same language. Not advertised developers will consider it like an error, and will spend time to understand wtf is that character. Please reconsider the question, and keep the good old "default" with new switch expression, or better anything like a lambda character ("default" included), like in Erlang and Clojure .

Regards


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

obewan avatar Aug 28 '19 17:08 obewan

I think the difference is that in a switch statement, you either write case pattern or default, while in a switch expression, you only write pattern. So it makes sense to use the discard pattern for the default, since using default would not actually be consistent.

Though C# 8.0 is going to be released very soon, so it's too late now to change that decision.

svick avatar Aug 28 '19 18:08 svick

The docs do correctly explain the switch expression. I'll close this as no action is needed on the documentation.

BillWagner avatar Aug 28 '19 20:08 BillWagner

To "switch expressions" mentioned here,

Instead of polluting the simple switch statement, Please introduce the keyword "map", something inline with F#.

dvbava avatar Sep 06 '19 13:09 dvbava