Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1a 12/4/83; site rlgvax.UUCP Path: utzoo!linus!philabs!seismo!rlgvax!guy From: guy@rlgvax.UUCP (Guy Harris) Newsgroups: net.lang Subject: Re: Strong Typing and Ignorance Message-ID: <1512@rlgvax.UUCP> Date: Sat, 31-Dec-83 16:05:09 EST Article-I.D.: rlgvax.1512 Posted: Sat Dec 31 16:05:09 1983 Date-Received: Sun, 1-Jan-84 02:28:19 EST References: <2892@utcsrgv.UUCP>, <137@csd1.UUCP> <718@cbosgd.UUCP>, <217@kobold.UUCP> <6421@unc.UUCP> Organization: CCI Office Systems Group, Reston, VA Lines: 23 The "?:" operator, which is a distributed conditional, can have differently typed alternative values. For instance, in the expression "i>0 ? 1 : 4.2", the type of the value of the expression cannot be determined until the value of i is known -- it might be int, or double. I don't know of any other exceptions to strong typing in C. According to the C Reference Manual: 7.13 Conditional operator ...If possible, the usual arithmetic conversions are performed to bring the second and third expressions to a common type; otherwise, if both are pointers of the same type, the result has the common type; otherwise, one must be a pointer and the other the constant 0, and the result has the type of the pointer. So the type of "i>0 ? 1 : 4.2" is double; the "1" is coerced to double so this expression is equivalent to "i>0 ? 1.0 : 4.2". Guy Harris {seismo,ihnp4,allegra}!rlgvax!guy