Which makes the assignment a side-effect of the conditional, and
depending on the context can be an excellent example of bad
side-effects, particularly from a software-engineering point of view,
where the code has to be maintained over any sort of time, by a team.
I think of it as the imperative corollary to duck-typing: if it looks
like a duck and sounds like a duck, it should *be* a duck.
There's a great public example of where this technique can break down
from an attempted hack on the linux kernal a couple of years ago. It's
worth noting that it was only caught because of 1) very tight, very
paranoid peer review, and 2) the secure nature of the project. It
would have gone through unnoticed virtually anywhere else. In my past
life doing telecoms programming, I can remember this exact pattern
being responsible for bringing down a good portion of the US East
Coast's 1-800 (and 900, etc) phone numbers.
To each their own, and if it's code for your own use it's unlikely to
matter, but assignment-as-conditional really, really smells bad to me.
http://kerneltrap.org/node/1584
+ if ((options == (__WCLONE|__WALL)) && (current->uid = 0))
+ retval = -EINVAL;
Associated commentary: