January 27, 2003
C#'s switch is safer than C/C++.  Or D for that matter.  However one thing that annoys me about it is that, if it's smart enough to know that break has to be there, why the #*@! do we have to type in "break;" after every case? Just get rid of it.

Damn C compatibility all to hell!

Sean

"Farmer" <itsFarmer.@freenet.de> wrote in message news:Xns930EAC5FDBCE5itsFarmer@63.105.9.61...
> Maybe C#'s switch statement would be great for D.
> It is as powerful as the current switch statement, but more bug-safe.
>
> Here's an example to get an idea how C#'s switch statement works:
>
> switch(i)
> {
> case 1: // explicit break statement is generally required
>      some_statement;
>      break;
> case 2: // compiler flags error, since break is missing here
>     some_statement;
> case 3: // "fall through" is allowed, as there are no statements here
> case 4:
>      some_statement;
>      break:
> case 5: // return or throw statements  can be used to "break" cases, too
>      some_statement;
>     return;
> case 6: // "fall through" with statements is possible with an explicit
goto
>      some_statement;
>     goto 7;
> case 7: // "fall through" with statements is possible with an explicit
goto
>      some_statement;
>      goto default;
> default:
> }
>
> Actually, in C# you have to write "goto case 7" instead of "goto 7".
>
>
>
> Farmer


February 24, 2003
"Daniel Yokomiso" <daniel_yokomiso@yahoo.com.br> wrote in message news:b0h3vm$1793$1@digitaldaemon.com...
> "Ilya Minkov" <midiclub@8ung.at> escreveu na mensagem news:b0h3bi$16tc$1@digitaldaemon.com...
> > The best thing to do for legibility are comments.
> > As i grow older, there become more comments and less code in my code.
> It's strange. As I grow older there is less comments in my code and more contracts/tests/granular functions ;-)

The problem with comments are they are invariably incorrect, incomplete, out of date, and wrong. As you said, contracts and unit tests can replace many comments.


1 2
Next ›   Last »