September 04, 2001
I don't know why my organization is listed as "Digital Mars" when I submit to this newsgroup. You should know that I am not in any way affiliated with Digital Mars, and so of course my opinions are my own and may differ dramatically from those of anyone who works at Digital Mars.

I'm using the Opera 5.11 web browser to interact with this newsgroup, and according to Opera, my email account is set up correctly with "TEC" as my organization.

I apologize in advance for any confusion that may arise from this matter; however, I don't currently know how to correct it.

September 05, 2001
Charles Jenkins wrote:
> PLEASE, whatever you do DON'T use the 'continue' keyword to modify the behavior of a switch; you need continue to behave exactly as in C, because switch statements are legal inside of loops!

	Just to play devil's advocate, you are arguing to change how switch
behaves so it is not like C.  But you don't want to affect how a
continue inside a switch behaves because it must be exactly as in C.  I
like the irony.  Don't get me wrong, I understand the convenience of it,
but since D has labeled breaks and continues, I'm not that worried.
Actually, I'm intoxicated by the power of labeled breaks and continues.
:-)

Dan
November 04, 2001
In C, switch wasn't that useful in loops because you couldn't do a break out of the loop from inside the switch.  If we remove the necessity for break inside switch, that frees up the keyword for breaking from containing loops again.

I'm perfectly happy with blocks instead of break.  And I'd rather use goto or goto case than have implicit fallthru.  That frees up both break and continue keywords.

I love the case ('b','c','e'..'h') { blah; } syntax, since that eliminates 99% of the cases where fallthrough was necessary and is cleaner and more powerful than C's case.

Pascal had a lot of these things right.  One of the few things I hated about Pascal were the wordiness, the special case for writeln, and lack of objects/generics.  Didn't like the Pascal cast syntax, but C's is troublesome too.  The builtin support for sets and ranges was wonderful.

Sean

"Charles Jenkins" <cjenkins@tec-usa.com> wrote in message news:1103_999632715@jenkins-lt...
> My two cents:
>
> 1. I like the idea of required braces instead of breaks. Break must still be permitted so that if statements within a case will work.
>
> 2. You don't need a fallthrough keyword if you have goto's. One enhancement might be to make labels inside of switch statements have the scope of the switch itself.
>
> 3. The ability to have multiple tests as part of a switch would be great! And you should also be able to test against any type, if possible.
>
> Here's an intentionally-convoluted example of a switch with these features:
>
>   switch ( c ) {
>     case 'a': {
>       Desired:
>       // unique part of this case goes here
>       goto AlwaysDo;
>     }
>     case ('b','c','d'): {
>       Acceptable:
>       // unique part of this case goes here
>       goto Desired;
>     }
>     case ('e'): {
>       // unique part of this case goes here
>       AlwaysDo:
>       // more stuff
>     }
>   } else {
>     // default case
>   }
>
> The compiler should generate an error if a case has no enclosing braces or if no label can be found as the target of a 'goto' statement. Naturally, labels within the scope of the switch statement take precendence over labels with the same name in some outer scope.
>
> PLEASE, whatever you do DON'T use the 'continue' keyword to modify the behavior of a switch; you need continue to behave exactly as in C, because switch statements are legal inside of loops!
>
>   for ( i = 0; i < n; ++i ) {
>     <snip>
>     switch ( command ) {
>       case CMD_SKIPONE: {
>         ++i;
>         continue;
>       }
>       <snip other cases>
>     }
>     <snip>
>   }
>
>


November 05, 2001
"Sean L. Palmer" wrote:

> In C, switch wasn't that useful in loops because you couldn't do a break out of the loop from inside the switch.  If we remove the necessity for break inside switch, that frees up the keyword for breaking from containing loops again.

Remember, though, that D has labeled breaks:

WHILE_LOOP: while(blah)
{
    SWITCH: swtich(bleh)
    {
    case 'a':
        foo();
        break WHILE_LOOP;
    default:
        bar();
     };
};

--
The Villagers are Online! http://villagersonline.com

.[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ]
.[ (a version.of(English).(precise.more)) is(possible) ]
?[ you want.to(help(develop(it))) ]


1 2 3
Next ›   Last »