January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote:
> What do you think?
>
> Stewart.
>
I think that the switch/case issue comes up way too often, considering how little use it gets. To date, I have only used D's switch/case to deal with win32-styled message handlers. (maybe I'm atypical in this regard)
That having been said, I suppose that means I'm neutral on the matter. ;)
-- andy
|
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | I think it's a great idea! Maybe, instead of 'switch', it should be 'select'. The syntax should be slightly changed, too, so as not to confuse C/C++/Java/C# programmers! Here's my idead: select(qwert) { where(1) // like 'case 1' { // do whatever } where(1 .. 3) { // do whatever } else // like default { // do if no 'where's are true } } (If you don't know, I got this syntax *sorta* from SQL) |
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ilya Minkov | I think it's a great idea! Maybe, instead of 'switch', it should be 'select'. The syntax should be slightly changed, too, so as not to confuse C/C++/Java/C# programmers! Here's my idead: select(qwert) { where(1) // like 'case 1' { // do whatever } where(1 .. 3) { // do whatever } else // like default { // do if no 'where's are true } } (If you don't know, I got this syntax *sorta* from SQL) P.S. Sorry if this double-posts :( |
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andy Friesen | Andy Friesen wrote: > Stewart Gordon wrote: > >> What do you think? >> >> Stewart. >> > > I think that the switch/case issue comes up way too often, considering how little use it gets. To date, I have only used D's switch/case to deal with win32-styled message handlers. (maybe I'm atypical in this regard) > > That having been said, I suppose that means I'm neutral on the matter. ;) > > -- andy Depends what your writing. If your were writing a state machine, then your view would probably be different. -- -Anderson: http://badmama.com.au/~anderson/ |
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to C | While it was 29/1/04 10:12 pm throughout the UK, C sprinkled little black dots on a white screen, and they fell thus: > Why do people put thier responses at the bottom :P. All that scrolling > makes me dizzy. <snip top of upside-down reply> Because they're not playing Jeopardy. However, the rest of us still shouldn't have to scroll to see it: http://smjg.port5.com/faqs/usenet/quote.html Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit. |
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote:
> While it was 29/1/04 10:12 pm throughout the UK, C sprinkled little black dots on a white screen, and they fell thus:
>
>> Why do people put thier responses at the bottom :P. All that scrolling
>> makes me dizzy.
>
> <snip top of upside-down reply>
>
> Because they're not playing Jeopardy.
LOL -- that's a good way of putting it.
|
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stephan Wienczny | While it was 29/1/04 9:26 pm throughout the UK, Stephan Wienczny sprinkled little black dots on a white screen, and they fell thus: > I like that idea. > I would make it an more generic expression instead of an block > then you could write: > > switch (qwert) > { > case 1 foo(); > > case 2 > { > foo2(); > } > } <snip top of upside-down reply> Potential ambiguity: case qwert ++ yuiop; Maybe with "code has no effect" being an error, that'll be only syntactic and not semantic ambiguity. But allowing it anyway would destroy context-free grammar. For that matter, will a property (which could have a side effect in itself) ever be able to take a ++? Moreover, case qwert (&yuiop) (asdfg(hjkl)); could be equivalent to case qwert(&yuiop) { asdfg(hjkl); } or case qwert { yuiop(asdfg(hjkl)); } which would both make sense if qwert is a property. Maybe requiring brackets like in F90 case (qwert) ++yuiop; would work, but still, letting that coexist in the language with the old-fashioned C syntax would still be a parsing nightmare. Stewart. -- My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment. Please keep replies on the 'group where everyone may benefit. |
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to J Anderson | J Anderson wrote:
>
> Depends what your writing. If your were writing a state machine, then your view would probably be different.
>
I usually use the GoF state pattern to implement FSMs, actually. :) It's much easier to work with.
-- andy
|
January 30, 2004 Re: [Suggestion] Alternative switch/case syntax | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote: > However, the rest of us still shouldn't have to scroll to see it: http://smjg.port5.com/faqs/usenet/quote.html I like paragraph 3 best :-) Olaf -- +-------------------------------------------------------------------+ I Dr. rer. nat. Olaf Rogalsky Institut fuer Theoretische Physik I I Universitaet Erlangen-Nuernberg I I Tel.: 09131 8528440 Staudtstr. 7 B3 I I Fax.: 09131 8528444 D-91058 Erlangen I | rogalsky@theorie1.physik.uni-erlangen.de I +-------------------------------------------------------------------+ |
January 31, 2004 OT: top posting (was Re: [Suggestion] Alternative switch/case syntax) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote: >> However, the rest of us still shouldn't have to scroll to see it: http://smjg.port5.com/faqs/usenet/quote.html >> Very cool! And that program advertised there (oe-quotefix) is really cool. It even replaces smileys :)! The link doesn't work, but I could dl it from http://home.in.tum.de/~jain/downloads/OEQuoteFix1192.exe. ----------------------- Carlos Santander Bernal |
Copyright © 1999-2021 by the D Language Foundation