How about a Hash template?

Jonathan M Davis jmdavisProg at gmx.com
Thu Apr 28 10:04:07 PDT 2011


> 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.

That should evaluate each of the expressions in order and take the value of 
the last one. So, ultimately, unless there are side effects to value == val1 
or implicitly converting val2 to bool (which there shouldn't be), then the 
result of the if condition will always be boolean equivalent of val3. That's 
not doing what you're looking for at all. And making it do what you want would 
alter the behavior of the comma operator, which wouldn't be good.

- Jonathan M Davis


More information about the Digitalmars-d mailing list