December 10, 2003
Agree whole-heartedly here, make it a compile time error will save everyone tons of headaches!  Why do at run-time when you can do at compile time ?

C

"Hauke Duden" <H.NS.Duden@gmx.net> wrote in message news:br7q79$1dub$1@digitaldaemon.com...
> Ilya Minkov wrote:
> > Vathix wrote:
> >
> >> This might make everyone happy:
> >>
> >>  - Have switch act exactly like C's switch; no implicit exception for
the
> >> default case. This allows you to port C code easier. People who like
C's
> >> switch may continue to use it.
> >
> >
> > Disagree strongly. Current D switch places no portability problems, since the imcopatibility is easy to track visually - and a code review is requiered when porting anyway, because array semantics is different.
> >
> > Even if gone unnoticed when reviewing, the oversight manifestates itself in a totally clear manner on the very first run.
>
> Huh? That's what this whole discussion is all about! If the error would occur on the very first run, then it would never be more than a small annoyance - no big deal.
>
> But it doesn't always happen at the first run. Not even necessarily in ANY of your test runs. Test cases can rarely cover all code paths, so that exception may never be thrown in your testing. It may still crash for the end user, though - which is bad!
>
> I could be happy with almost any solution that would trigger the error while I still had the code in my own hands. Preferably at compile time. That's why I support the mandatory default - no matter which way you want the default, the compiler will always warn you right there, when you compile the code.
>
> Hauke


December 11, 2003
Vathix wrote:

> This might make everyone happy:
> 
>  - Have switch act exactly like C's switch; no implicit exception for the
> default case. This allows you to port C code easier. People who like C's
> switch may continue to use it.
> 
>  - Add a new branch construct that has our new ideas. select is a good name
> too but there's a common C function with that name. Maybe like this:
> 
> branch(val)
> {
>     case(3) { }
>     case(2, 4) { }
>     case(5 .. 8) { }
>     default { }
> }
> 
> The default might not need to implicitly throw an exception because the
> cases won't fall through.
> 
> 
> Is this a good solution?  Everyone want a copy of my victory music tape? :+P
> 
> 
> 
> 

i agree that one should leave the switch statement as is, to have it act unexpectedly to people who have used it for years isnt optimal IMO. I am strongly on the side of introducing a new construct like this one. (not that my opinion matters here lol)
December 11, 2003
Lewis wrote:
> i agree that one should leave the switch statement as is, to have it act unexpectedly to people who have used it for years isnt optimal IMO. I am strongly on the side of introducing a new construct like this one. (not that my opinion matters here lol)

On the other hand, if someone is going to break switch/case, this is one of the best possible times. (no established language would dare doing such a thing)

 -- andy
December 11, 2003
Yeah, and the time will decide... Maybe D version 2 will drop the switch completely...


In article <br91di$6po$2@digitaldaemon.com>, Lewis says...
>
>Vathix wrote:
>
>> This might make everyone happy:
>> 
>>  - Have switch act exactly like C's switch; no implicit exception for the
>> default case. This allows you to port C code easier. People who like C's
>> switch may continue to use it.
>> 
>>  - Add a new branch construct that has our new ideas. select is a good name
>> too but there's a common C function with that name. Maybe like this:
>> 
>> branch(val)
>> {
>>     case(3) { }
>>     case(2, 4) { }
>>     case(5 .. 8) { }
>>     default { }
>> }
>> 
>> The default might not need to implicitly throw an exception because the cases won't fall through.
>> 
>> 
>> Is this a good solution?  Everyone want a copy of my victory music tape? :+P
>> 
>> 
>> 
>> 
>
>i agree that one should leave the switch statement as is, to have it act unexpectedly to people who have used it for years isnt optimal IMO. I am strongly on the side of introducing a new construct like this one. (not that my opinion matters here lol)


December 11, 2003
"Lewis" <dethbomb@hotmail.com> wrote in message news:br91di$6po$2@digitaldaemon.com...
> Vathix wrote:
>
> > This might make everyone happy:
> >
> >  - Have switch act exactly like C's switch; no implicit exception for
the
> > default case. This allows you to port C code easier. People who like C's switch may continue to use it.
> >
> >  - Add a new branch construct that has our new ideas. select is a good
name
> > too but there's a common C function with that name. Maybe like this:
> >
> > branch(val)
> > {
> >     case(3) { }
> >     case(2, 4) { }
> >     case(5 .. 8) { }
> >     default { }
> > }
> >
> > The default might not need to implicitly throw an exception because the cases won't fall through.
> >
> >
> > Is this a good solution?  Everyone want a copy of my victory music tape?
:+P
> >
> >
> >
> >
>
> i agree that one should leave the switch statement as is, to have it act unexpectedly to people who have used it for years isnt optimal IMO. I am strongly on the side of introducing a new construct like this one. (not that my opinion matters here lol)

Everyone's opinion matters. :)


December 11, 2003
"Matthew Wilson" <matthew.hat@stlsoft.dot.org> wrote in message news:br9bhn$p66$1@digitaldaemon.com...
> > i agree that one should leave the switch statement as is, to have it act unexpectedly to people who have used it for years isnt optimal IMO. I am strongly on the side of introducing a new construct like this one. (not that my opinion matters here lol)
>
> Everyone's opinion matters. :)

You'd like to believe that, wouldn't you?  ;)

Apparently our opinions only matter if we are able to express them compellingly enough that Walter changes his mind.  Which is not easy.

Sean


December 11, 2003
"Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:brai2b$2jj9$1@digitaldaemon.com...
> "Matthew Wilson" <matthew.hat@stlsoft.dot.org> wrote in message news:br9bhn$p66$1@digitaldaemon.com...
> > > i agree that one should leave the switch statement as is, to have it
act
> > > unexpectedly to people who have used it for years isnt optimal IMO. I
am
> > > strongly on the side of introducing a new construct like this one.
(not
> > > that my opinion matters here lol)
> >
> > Everyone's opinion matters. :)
>
> You'd like to believe that, wouldn't you?  ;)
>
> Apparently our opinions only matter if we are able to express them compellingly enough that Walter changes his mind.  Which is not easy.

Well I was being a bit existentialist, and a bit nice (I thought I'd try it out, so see how it feels).

However, despite Walter's recent post saying something about sometimes having to pick something and stick with it or nothing will get done, I don't believe that he is 100% intractable on any issue. Given the clear unpopularity of the switch issue, and people's unwillingness to drop it, I can't believe he'd be so foolhardy as to simply thumb his nose at us. After all, we're not all hot under the collar on this issue because we think D is shit, or we want it to fail. Quite the contrary, we like D and we want it to succeed, and we don't want it to have such clear warts on it that will (rightly) bring strong criticism from anyone who does seek to do it down. If this weren't the case why would we bother; I've already said that putting in the default is as automatic to me as putting in braces for every conditional block, so it's not going to hurt me, just people new to the language with different habits to mine (and Walter's!).

But you're right. It's not easy to get him to change his mind.



December 11, 2003
Andy Friesen wrote:
> On the other hand, if someone is going to break switch/case, this is one of the best possible times. (no established language would dare doing such a thing)

Yeah, but I think if you're going to break switch you should at least name it differently.

But I think I've said enough on this issue... ;)

Hauke
December 11, 2003
Matthew Wilson wrote:

>"Sean L. Palmer" <palmer.sean@verizon.net> wrote in message
>news:brai2b$2jj9$1@digitaldaemon.com...
>  
>
>>"Matthew Wilson" <matthew.hat@stlsoft.dot.org> wrote in message
>>news:br9bhn$p66$1@digitaldaemon.com...
>>    
>>
>>>>i agree that one should leave the switch statement as is, to have it
>>>>        
>>>>
>act
>  
>
>>>>unexpectedly to people who have used it for years isnt optimal IMO. I
>>>>        
>>>>
>am
>  
>
>>>>strongly on the side of introducing a new construct like this one.
>>>>        
>>>>
>(not
>  
>
>>>>that my opinion matters here lol)
>>>>        
>>>>
>>>Everyone's opinion matters. :)
>>>      
>>>
>>You'd like to believe that, wouldn't you?  ;)
>>
>>Apparently our opinions only matter if we are able to express them
>>compellingly enough that Walter changes his mind.  Which is not easy.
>>    
>>
>
>
>Given the clear
>unpopularity of the switch issue, and people's unwillingness to drop it, I
>can't believe he'd be so foolhardy as to simply thumb his nose at us. After
>all, we're not all hot under the collar on this issue because we think D is
>shit, or we want it to fail. Quite the contrary, we like D and we want it to
>succeed, and we don't want it to have such clear warts on it that will
>(rightly) bring strong criticism from anyone who does seek to do it down. 
>  
>
Even C# changed the switch statement.  There must have been allot of pressure on MS to do this.
http://msdn.microsoft.com/vcsharp/team/language/ask/switch/default.aspx

December 12, 2003
Yeah, I like the "goto" style, it is the most useful in a switch. No joke



In article <brask8$21c$1@digitaldaemon.com>, J Anderson says...
>
>Matthew Wilson wrote:
>
>>"Sean L. Palmer" <palmer.sean@verizon.net> wrote in message news:brai2b$2jj9$1@digitaldaemon.com...
>> 
>>
>>>"Matthew Wilson" <matthew.hat@stlsoft.dot.org> wrote in message news:br9bhn$p66$1@digitaldaemon.com...
>>> 
>>>
>>>>>i agree that one should leave the switch statement as is, to have it
>>>>> 
>>>>>
>>act
>> 
>>
>>>>>unexpectedly to people who have used it for years isnt optimal IMO. I
>>>>> 
>>>>>
>>am
>> 
>>
>>>>>strongly on the side of introducing a new construct like this one.
>>>>> 
>>>>>
>>(not
>> 
>>
>>>>>that my opinion matters here lol)
>>>>> 
>>>>>
>>>>Everyone's opinion matters. :)
>>>> 
>>>>
>>>You'd like to believe that, wouldn't you?  ;)
>>>
>>>Apparently our opinions only matter if we are able to express them compellingly enough that Walter changes his mind.  Which is not easy.
>>> 
>>>
>>
>>
>>Given the clear
>>unpopularity of the switch issue, and people's unwillingness to drop it, I
>>can't believe he'd be so foolhardy as to simply thumb his nose at us. After
>>all, we're not all hot under the collar on this issue because we think D is
>>shit, or we want it to fail. Quite the contrary, we like D and we want it to
>>succeed, and we don't want it to have such clear warts on it that will
>>(rightly) bring strong criticism from anyone who does seek to do it down.
>> 
>>
>Even C# changed the switch statement.  There must have been allot of pressure on MS to do this. http://msdn.microsoft.com/vcsharp/team/language/ask/switch/default.aspx
>