syntax idea: simplifed ifs

dennis luehring dl.soluz at gmx.net
Tue Apr 11 00:01:46 PDT 2006


> I've always wanted something like this!!!! but I think the proposed 
> syntax might not fit very well with the D grammar.

another idea

> hmm, come to think of it, maybe it can already be implemented with 
> templates.

oh no! what we need is more syntactic sugar - not another boost library 
(hell) :-)

> so,
> 
> if( x == 10 || x == 20 || x == 30 )
> 
> becomes:
> if( equals!(x).anyOf( 10, 20, 30 ) )
> 
> or something like that!
> 
> any template guru up to it?
> 
> On a side note: the expression( x == 10 && x == 20 && x == 30 ) is 
> rediclious, it's always false ;)

example version 2:

if( x == a && x == b && x == c )

=>

if( x == [a && b && c] )

--> or maybe even "if( x == [a,b,c](&&))"
but this goes a little bit to fast into the "how can we integrate vector 
stuff" direction...

ciao dennis



More information about the Digitalmars-d mailing list