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.

:-)

Reply via email to