Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!ucbcad!ucbvax!cbatt!danews!lvc From: lvc@danews.UUCP Newsgroups: comp.lang.c Subject: Two replacements for unary + Message-ID: <489@danews.ATT.COM> Date: Thu, 16-Apr-87 07:07:08 EST Article-I.D.: danews.489 Posted: Thu Apr 16 07:07:08 1987 Date-Received: Sun, 19-Apr-87 01:51:55 EST Organization: AT&T Medical Information Systems, Columbus, Oh Lines: 47 I am very dissatisfied with unary plus in the ANSI C. Here are two possible replacements, both of which might not work, but what the heck. The first is to use a special cast called (eval) (or some other appropriate word). It would be used like this: x = (eval)(a + b) + c; In this statement the sum 'a + b' would be computed first, then that would be added to 'c'. x = (eval)(a * b) * (eval)(c * d) Here the products 'a * b' and 'c * d' would be computed, and then they would be multiplied together. (messy huh?) Cast already has the correct precedence for this to work (no?). Furthermore, casts are already in C language. Does anyone see a problem with this approach? Is associativity of cast a problem? The second method I thought of on the way to work this morning, so its less clear to me that it would work and be useful. Instead of using () to separate the operands to be evaluated, we can use [] instead. For example: x = [a + b] + c; and x = [a * b] * [c * d]; The nice thing about this is that it is visually appealing (at least to me), [] has the highest precedence in C along with () and -> and . The problems I see with it are that existing compilers may have to change radically for this work, and secondly, it solves a somewhat different problem than was originally meant to be solved (ie grouping of paren- thesis). -- Larry Cipriani, AT&T Network Systems, Columbus OH, (614) 860-4999