Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!yale!mfci!karzes From: karzes@mfci.UUCP (Tom Karzes) Newsgroups: comp.lang.c Subject: Re: syntax for unary assignment operators (was Re: C history question) Keywords: C design, XOR Message-ID: <1036@m3.mfci.UUCP> Date: 19 Sep 89 16:22:14 GMT References: <575@calmasd.Prime.COM> <1687@sunset.MATH.UCLA.EDU> <174@cpsolv.UUCP> <1989Sep17.150504.16643@jarvis.csri.toronto.edu> <1032@m3.mfci.UUCP> <2562@jhunix.HCF.JHU.EDU> Sender: karzes@mfci.UUCP Reply-To: karzes@mfci.UUCP (Tom Karzes) Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 24 In article <2562@jhunix.HCF.JHU.EDU> ins_akaa@jhunix.UUCP (Ta06) writes: ->>A somewhat consistent but fairly bizarre syntax would be ->> x -=; ->The problem with this is that you would like it to have the same precedence ->as ++ and --. ... - -Why? We don't expect the regular += to have the same precedence as +... Because all unary operators in C have the same precedence, which is higher than the precedence of any binary or ternary operator (other than the primary expression operators). Introducing a unary operator with lower precedence than assignment would be a disgusting wart. Furthermore, it would make C agonizing to parse. What would the rules be for deciding when to reduce x-= as opposed to looking for some expression following it? Since you naively think that binary -= should have higher precedence than unary -=, it means that you'd always have to look beyond the -= to see if there's something there that you can use as a second operand. So you wouldn't be able to write x -= * 3 because this would be parsed as x -= (*3), but you might be able to write x -= / 3 since / isn't a valid unary operator. The whole thing it utterly absurd. As for += not having the same precedence as +, what does that have to do with anything? All binary assignment operators in C have the same precedence, which is lower than the precedence of +.