The ternary operator is indeed special as it (is the only one AFAIK that) introduces in the language some type constraints between the two result branches, that affect the way one or the other is interpreted.<p>A similar trick in C++ is explained on <a href="https://www.artima.com/cppsource/foreach2.html" rel="nofollow">https://www.artima.com/cppsource/foreach2.html</a> and allows to return the type of an expression <i>without evaluating it</i>.<p>From the link:<p>> You may be thinking this is needlessly convoluted. After all, couldn't we just use encode_type(container) without the conditional operator and get the same result? No, because that would have caused container to be evaluated. With the conditional operator, only one branch of the condition is ever executed. In this case, since the condition is always true, the first branch will always be taken. The second branch is "dead code"—it will never execute—yet it extends a ghostly finger into the land of the living and exerts its influence on the conditional expression's type. Spooky!
With apologies to Philip Greenspun:<p>Any sufficiently complicated C program contains an ad-hoc, informally-specified, bug-ridden, slow implementation of half of C++.
I always thought it was setjmp.<p><a href="https://en.wikipedia.org/wiki/Setjmp.h" rel="nofollow">https://en.wikipedia.org/wiki/Setjmp.h</a>