February 01, 2004
>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

yes please snip out all that is not relevent to the reply. We have all learned
how to cut text by now.
thank you


May 19, 2004
In article <bvb6lc$1t7a$1@digitaldaemon.com>, Stewart Gordon says...
>
>In line with the multiple syntaxes for align and member access keywords, it would make sense to have this syntax for cases:
>
>	switch (qwert) {
>		case 1 {
>			yuiop = 3;
>		}
>		case 2 {
>			yuiop = 4;
>		}
>		case 3, 4, 5 {
>			yuiop = 5;
>		}
>	}
>
>(Note no colons)
>
>The idea:
>- Having the case clauses as block statements seems the logical thing to me.
>
>- Declarations/initialisations local to case clauses - I know you can do
>
>	case 1: {
>		Asdfg hjkl = new Asdfg;
>		// ...
>	} break;
>
>but I still think my idea is neater.
>
>- When this syntax is used, there would be no default fall-through - it would simply execute the block specified by the parameter.  Further, it could be permissible for cases to overlap, in which case (NPI) all would be executed.  Maybe an 'else' could be used to override this, e.g.
>
>	switch (qwert) {
>		case 0, 5, 10 {
>			// do stuff if qwert is 0, 5 or 10
>		} else case 1..9 {
>			/* do stuff if qwert is 1, 2, 3, 4, 6, 7, 8 or 9
>			 * (or should this be semi-inclusive like array
>			 * slicing?)
>			 */
>		}
>
>		case 6..13 {
>			/* do stuff if qwert is 6..13, even if a
>			 * previous case matched
>			 */
>		}
>
>		default {
>			// this would still mean do stuff if  none match
>		}
>	}
>
>Nesting could also be allowed, for a bit of syntactic sugar:
>
>	switch (qwert) {
>		case 0..10 {
>			// do something
>
>			case 4 {
>				// do something more specific
>			}
>
>			// now do something else
>		}
>	}
>
>What do you think?
>
>Stewart.

That is sometimes pretty damn useful, specially the boolean switch "case (a>b)".
(If there are two different cases which can be "true", just pick up the first
one).

It's a pity things syntactic tricks like that one weren't included in Java at its time...

D isn't set-in-stone yet, so this could be a neat inclusion :) .


May 21, 2004
LordSyl wrote:

<snip excessive quote>
>>		case 0, 5, 10 {
>>			// do stuff if qwert is 0, 5 or 10
>>		} else case 1..9 {
>>			/* do stuff if qwert is 1, 2, 3, 4, 6, 7, 8 or 9
>>			 * (or should this be semi-inclusive like array
>>			 * slicing?)
>>			 */
>>		}
>>
>>		case 6..13 {
>>			/* do stuff if qwert is 6..13, even if a
>>			 * previous case matched
>>			 */
>>		}
<snip>
> That is sometimes pretty damn useful, specially the boolean switch "case (a>b)".
> (If there are two different cases which can be "true", just pick up the first
> one).
<snip>

You unnecessarily quoted my whole post, but did you read my whole post?  The 'pick up the first one' and 'pick up all' possibilities are perfectly there, just as they are with if.

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.
1 2 3
Next ›   Last »