syntax idea: simplifed ifs
Derek Parnell
derek at psych.ward
Mon Apr 10 17:17:30 PDT 2006
On Mon, 10 Apr 2006 18:03:57 -0600, Hasan Aljudy wrote:
> dennis luehring wrote:
>> for example how often do we use constructs like
>>
>> if( x == 10 && x == 20 && x == 30 )
>>
>> simplified:
>> if( x == [10 && 20 && 30] )
>>
>> if( a >= h && b >= h && c >= h )
>>
>> simplified:
>> if( [a && b && c] >= h )
>>
>> (just an idea)
>>
>> ciao dennis
>
> I've always wanted something like this!!!! but I think the proposed
> syntax might not fit very well with the D grammar.
>
> hmm, come to think of it, maybe it can already be implemented with
> templates.
>
> 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 ;)
Try not using literals ... ;-)
The expression( x == a && x == b && x == c ) is not always false.
--
Derek
(skype: derek.j.parnell)
Melbourne, Australia
"Down with mediocracy!"
11/04/2006 10:15:53 AM
More information about the Digitalmars-d
mailing list