Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!brl-adm!adm!jeff@slovax.uucp From: jeff@slovax.uucp Newsgroups: comp.lang.c Subject: Re: Two replacements for unary + Message-ID: <7017@brl-adm.ARPA> Date: Tue, 21-Apr-87 10:57:34 EST Article-I.D.: brl-adm.7017 Posted: Tue Apr 21 10:57:34 1987 Date-Received: Wed, 22-Apr-87 03:20:40 EST Sender: news@brl-adm.ARPA Lines: 61 in article <489@danews.ATT.COM>, lvc@danews.ATT.COM (Larry Cipriani) says: > I am very dissatisfied with unary plus in the ANSI C. .. > 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? I like this idea. For one, it deals with the context of the expression, not the content. The purpose is to communicate to the compiler that one portion of an expression should be evaluated first. The unary '+' will do the same, but at the expense of creating a compiler directive disguised as an operator. All other arithmetic operators are subject to optimization. Why not the unary '+' ??? Because it's a special case !!! The unary '+' is needed as just that -- the other half of unary '-'. It should be subject to the same compiler interpretation. if -( a - b ) + z can become z + b - a { evaluated left to right } why can't +( a -b ) + z become z + a - b { evaluated left to right } ??? Let's use compiler directives that are distinct from arithmetic operators. It doesn't mess up the language with special cases that confuse the novice and confound the compiler writter. Thanks for your time. ---------------- uw-beaver!tikal!slovax!jeff (jeff loucks) ----------------- terrorist cryptography DES drugs cipher secret decode NSA CIA NRO IRS coke crack pot LSD russian missile atom nuclear assassinate libyan RSA infiltrate smuggle (suck it up there NSA !!) (really now, is this any way to act ???) ----------------------------------------------------------------------------- -- ---------------- uw-beaver!tikal!slovax!jeff (jeff loucks) ----------------- terrorist cryptography DES drugs cipher secret decode NSA CIA NRO IRS coke crack pot LSD russian missile atom nuclear assassinate libyan RSA infiltrate smuggle (suck it up there NSA !!) (really now, is this any way to act ???) -----------------------------------------------------------------------------