How about a Hash template?

Peter Alexander peter.alexander.au at gmail.com
Fri Apr 29 05:22:58 PDT 2011


On 29/04/11 10:31 AM, Jacob Carlborg wrote:
> On 2011-04-28 18:20, Andrej Mitrovic wrote:
>> Well, DMD accepts this kind of syntax already:
>>
>> if (value == val1, val2, val3) { }
>>
>> I think this turns the expression value==val1 into a bool, and then
>> turns val2 and val3 into bools and compares against each of them. Or
>> something like that. It's odd and I've never seen it used anywhere.
>>
>> Maybe we could put that syntax into good use.
>
> Wouldn't it be nice if you could do something like this:
>
> if (value == (3 || 4)) {}
>
> And the compiler turns that into:
>
> if (value == 3 || value == 4) {}
>

Sure, if you like ambiguous grammars that break a fundamental property 
of expressions.

:-)


More information about the Digitalmars-d mailing list