Path: utzoo!attcan!uunet!lll-winken!ames!purdue!decwrl!decvax!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.std.c Subject: Re: C's triadic operator. Message-ID: <13279@haddock.ima.isc.com> Date: 23 May 89 15:46:46 GMT References: <26212@watmath.waterloo.edu> <10266@smoke.BRL.MIL> <26388@watmath.waterloo.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 17 In article <26388@watmath.waterloo.edu> rbutterworth@watmath.waterloo.edu (Ray Butterworth) writes: >[If the operands are brought to the common type (void *), then you silently >get nonsense from the (incorrect) code] > if (!dbuf) dbuf = sbuf ? sbuf : ( cbuf ? cbuf : malloc(1000) ); >[On the other hand, if the result has the non-voidptr type, then you could >lose information from the (plausible) code] > vp = cond ? dp : vp; Looks to me as though the "right" answer would have been to insist that the operands shall have the same type%. Let the user explicitly specify which one is meant; this ought to reduce the "surprise factor". Hopefully, quality implementations will have an option to warn about such constructs. I always use an explicit cast on type conversions anyway. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint % With the usual exception when one operand is a null pointer constant.