Switch

Michel Fortin michel.fortin at michelf.com
Mon May 18 20:35:49 PDT 2009


On 2009-05-18 22:39:23 -0400, Andrei Alexandrescu 
<SeeWebsiteForEmail at erdani.org> said:

> I'd like to keep the (non-required) colon after the first expression in 
> a ".." pair of case labels, that is:
> 
> case '0': .. case '9':
> 
> as opposed to
> 
> case '0' .. case '9':
> 
> That way it is abundantly clear that the notation has nothing in common 
> with expression1 .. expression2. The error message if someone forgot 
> the ':' can easily be made clear.

You could have '::' denote an inclusive range. :-)

	case '0'..'9': // '9' excluded
	case '0'::'9': // '9' included

Seriously, I don't care much what the syntax is as long as it's 
different from the one used for exclusive range. Both:

	case '0': .. case '9':

looks acceptable to me. Although I agree with others about the 
inconsistency of using ".." for an inclusive range, having it finish 
with "case '9':" seems to indicate clearly the intent to include the 
last element.


-- 
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/




More information about the Digitalmars-d mailing list