Re: Can someone explain why switch syntax is the way it is?




"Andrew Ducker" <andrew@xxxxxxxxxxxxx> wrote in message
news:1129209462.752861.88480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> And no, this isn't a complaint about break - I'm very happy to make
> things explicit.
>
> However, why isn't the format something like:
>
> switch(myVariable)
> {
> case 1:
> {
> //Do Something
> }
> case 2:
> {
> //Do Something Else
> }
> default
> // Do Nothing at all
> }
>
> That way the 'break' is subsumed into the closing curly brackets, and
> it follows the same way of grouping commands as the rest of the
> language does.
>
> Andy D

Well, it would certainly be more "C# like" that way, but it would prevent
intentional "flow through" from one case to another. While I think such
"flow through" is a horrible, horrible idea, I'm sure someone out there
thinks it's absolutely necessary.


.



Relevant Pages

  • Re: Can someone explain why switch syntax is the way it is?
    ... this isn't a complaint about break - I'm very happy to make ... > things explicit. ... why isn't the format something like: ... Simply exiting a switch statement on reaching the end ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Can someone explain why switch syntax is the way it is?
    ... this isn't a complaint about break - I'm very happy to make ... >> things explicit. ... why isn't the format something like: ... > intentional "flow through" from one case to another. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Can someone explain why switch syntax is the way it is?
    ... this isn't a complaint about break - I'm very happy to make ... >> things explicit. ... > intentional "flow through" from one case to another. ... alternative format really does not seem to add any confusion - it is just as ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: cyrus behaves the down on to hers and indirectly aims
    ... explicit doubts are urgent, but will Pervez fade that? ... It might anticipate beyond if Abduljalil's flow isn't universal. ...
    (sci.crypt)
  • Re: style issue
    ... This message is posted to a newsgroup. ... >> I have a style called "Flow" which is used when I list steps in a flow. ... So I have typed the first paragraph in the ... >> So I go to Format, Styles and Formatting and modify the style. ...
    (microsoft.public.word.pagelayout)