syntax idea: simplifed ifs

BCS BCS_member at pathlink.com
Tue Apr 11 09:29:21 PDT 2006


>
>The suggestions parse as arrays, which is unfriendly to context-free  
>grammar...
>
>static int[] foo = [1 && 2 && 3];
>static int[] bar = [ 1, 2, 3 ];
>writefln(foo, bar);


Why not let it?

Compound_expr :: Expr Rel_op ArrayExpr
Compound_expr :: ArrayExpr Rel_op Expr


If you always assume "or" you can still make things work.


int[] a = [1, 2, 3];
int b;

// b is equal to one or more of a
if(a == b){...}   
// b is not equal to any of a
if(!(a == b)){...}   

// b is less than at least one of a
if(a > b){...}
// b is less than all of a
if(!(a < b)){...}

// b is more than at least one of a
if(a < b){...}
// b is more than all of a
if(!(a > b)){...}




More information about the Digitalmars-d mailing list