--- Comment #22 from Jonathan M Davis <> 2012-01-18 13:50:26 
PST ---
> `if (x = foo())` can't work, so I don't know why `switch (x = foo())` can.

That's easy. With if, there's a strong possibility that the programmer really
meant to use ==. So, by disallowing = by itself, you avoid those bugs (though
it would certainly be nice to be able to do if(x = foo()) - gcc allows it
without complaining if you add extra parens (though IIRC Visual Studio doesn't
like it) - if((x = foo()) - but I don't think that D has anything of the sort).

However, the switch statement requires a value, not an expression, so the risk
of = being used instead of == is pretty much zero. So, disallowing it for
switch doesn't really benefit anyone.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to