"with" still sucks + removing features + adding features

Georg Wrede georg.wrede at iki.fi
Mon May 18 19:43:56 PDT 2009


Andrei Alexandrescu wrote:
> Bill Baxter wrote:
>> On Mon, May 18, 2009 at 4:15 PM, Bill Baxter <wbaxter at gmail.com> wrote:
>>>> But it's not "blarf". It's "case". I am floored that nobody sees the
>>>> elegance of that syntax.
>>> So your argument is that "case" inherently deserves a special case?
>>
>> Thinking about it more, I guess you must actually be seeing it as a
>> rule of   " '..' always does the most useful thing", and the most
>> useful thing for switches is inclusive.
> 
> No! If I thought that, I would have said this is fine:
> 
> case 'a' .. 'z':
> 
> It is NOT fine because 'a' .. 'z' means one thing here and a different 
> thing in another place. So I went for:
> 
> case 'a': .. case 'z':
> 
> specifically because case 'a': .. case 'z': does NOT have any meaning 
> anywhere else.

The colon is not needed there for understanding, and definitely not 
needed for remembering that .. in a case is inclusive. It's the overall 
context (being in a switch statement) that puts the programmer in the 
inclusive mindset.

     case 'a' .. case 'z':

is adequate. Besides, then we can have discontinuous ranges without 
changing the current behavior, since

     case 'a' .. case 'z':
     case 'A' .. case 'Z':
         do something

is the same as

     case 'a' .. case 'z': case 'A' .. case 'Z':
         do something

already now.



More information about the Digitalmars-d mailing list