How about a Hash template?

Jacob Carlborg doob at me.com
Fri Apr 29 06:15:19 PDT 2011


On 2011-04-29 14:22, Peter Alexander wrote:
> 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.
>
> :-)

Well, I didn't think THAT far ahead :) . It just looks like a nice syntax.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list