"with" still sucks + removing features + adding features

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon May 18 20:05:14 PDT 2009


Derek Parnell wrote:
> On Mon, 18 May 2009 19:38:05 -0500, Andrei Alexandrescu wrote:
> 
>> I like my syntax better than all you mentioned, by a mile.
> 
> Problem: Define a syntax that indicates a specific range of values for a
> single case statement.
> 
> Constraints:

(0) Must be recognizable and understood at first sight without the user 
running to the manual and looking it up.

> (1) No new keywords permitted.
> (2) No new operators permitted.
> (3) Must indicate an *inclusive* range
> (4) A range has an explicit starting value and ending value
> (5) A range has an implicit step value of 1.
> (6) Must not be keystroke-heavy
> (7) Must be easy to read
> (8) Must be easy to remember while writing
> (9) Must not be ambiguous with existing syntax
> (10) Must be consistent with existing syntax
> (11) Must take the general form ...
> 
>     'case' RANGE ':'
> 
> 
> Andrei ...
>   case FIRST .. case LAST :
>    [[ -(8)- The second 'case' is easy to forget to write ]]

Compile-time error.

>    [[ -(10)- The ".." means exclusive range elsewhere but not here ]]

NO. NO. NO. BY GOLLY NO. Please understand the very basics of a grammar. 
I swear this is the last time I explain that.

".." is a TOKEN. TOKEN. TOKEN. Punctuation. It is NOT any grammatical 
construct in particular.

expression1 .. expression2

is a notation for ranges. All elements must be present. ".." by itself 
does not have a meaning.

case expression1: .. case expression2:

is an entirely different construct. It does not have expression1 .. 
expression2 anywhere in sight. It is ridiculous to attribute meaning to 
".." alone as much as saying that "(" must only used to initiate a 
function call or "[" must be only used to initiate an array indexing 
operation.

> bearophile ...
>   case FIRST .. LAST+1 :
>    [[ -(8)- The +1 is easy to forget to write ]]
> 
> JB (first pass)
>   case FIRST .. LAST :
>    [[ -(10)- inconsistent with exclusive range syntax]]
> So just as a thought without a lot of adademic introspection 
> 
> derek ...
>   case [FIRST ; LAST] :

Fails (0) with flying colors.


Andrei



More information about the Digitalmars-d mailing list