"with" still sucks + removing features + adding features
Jeremie Pelletier
jeremiep at gmail.com
Mon May 18 20:15:17 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:
> (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 ]]
> [[ -(10)- The ".." means exclusive range elsewhere but not here ]]
>
> 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] :
Personally I feel that your syntax breaks the condition
(6) Must not be keystroke-heavy
I like Andei's syntax best but as previously stated, its ambiguous with exclusive ranges.
Maybe the solution is a second range operator that is inclusive, such as:
case FIRST ... LAST:
I don't feel it breaks the no new operator rule as ... is already handled by the lexer, and it is obvious to the parser what the intended usage is. Also the operator can be generalized to all range statements.
Jeremie
More information about the Digitalmars-d
mailing list