Orphaned Response

karl at haddock karl at haddock
Mon Aug 11 11:21:00 AEST 1986


[In the expression "cond ? voidf() : voidf()",]
>The void values are not thrown away!

True.  They are being passed to the ?: operator.

>Remember that (A?B:C) is an expression *returning a value*.

Yes, it is an expression (as opposed to a statement); however, some
expressions have type "void" (and no value).  This is (or should be)
one of them.

>C is giving the error because it can't determine the type.

No, it's giving the error because the compiler writer overlooked a case.
I'm glad X3J11 has fixed this.

Btw, a case where it could be useful (and where if...else won't do) is
"(cond ? voidf0() : voidf1()), intf2())" used in an integer context.  I
admit I have no plans to use this feature in the near future, but it's a
perfectly reasonable thing to allow.

Karl W. Z. Heuer (ihnp4!ima!haddock!karl), The Walking Lint



More information about the Comp.lang.c mailing list