Problem with ()?():() as ending test in for-loop

Bjorn Engsig bengsig at oracle.nl
Thu May 25 21:04:16 AEST 1989


In article <17722 at mimsy.UUCP> chris at mimsy.UUCP (Chris Torek) writes:
>  (Any valid `logical' [true/false]
>e1?e2:e3 expression can always be transformed this way into (e1&&e2)||e3,
>provided e3 has no side effects.)
No Chris, this was a bit too fast.  If e1!=0 and e2==0, (e1&&e2)||e3 evaluates
e3 and returns it's truth value, whereas (e1?e2:e3) returns 0 and does not
evaluate e3.
-- 
Bjorn Engsig, ORACLE Europe         \ /    "Hofstadter's Law:  It always takes
Path:   mcvax!orcenl!bengsig         X      longer than you expect, even if you
Domain: bengsig at oracle.nl           / \     take into account Hofstadter's Law"



More information about the Comp.lang.c mailing list