Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!sdcsvax!sdcc6!ix426 From: ix426@sdcc6.ucsd.EDU (tom stockfish) Newsgroups: comp.lang.c Subject: Re: Power proposal for ANSI C Message-ID: <3594@sdcc6.ucsd.EDU> Date: 23 Jan 88 07:22:25 GMT References: <38384@sun.uucp> <2252@haddock.ISC.COM> <3421@ihlpf.ATT.COM> <2335@haddock.ISC.COM> <3474@ihlpf.ATT.COM> Reply-To: ix426@sdcc6.ucsd.edu.UUCP (tom stockfish) Organization: University of California, San Diego Lines: 70 In article <3474@ihlpf.ATT.COM> nevin1@ihlpf.UUCP (00704A-Liber,N.) writes: > _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 > >1. (); []; .; -> (left to right) >2. postfix unary (right to left) >3. power (right to left) >4. prefix unary (right to left) >5. *; /; % (left to right) >6 and below. the same as K&R > >.... If power were to be added (PLEASE DON'T), I believe it >should have a precedence below the unaries but above {*; /; and %) and >associate left to right; it would match closer to the mathematical definition >this way. No, please don't propose this precedence. Expressions like -x*^2 + 5 will occur often and will make people hate C (where "*^" is the proposed power op). Any power operator proposal *must* get this one right. >Also, notice that all the right to left operators are either >assignment or unary; Wrong. "? :" groups right to left (K&R appendix notwithstanding). >having an augmented assignment operator for an operator >which groups right to left seems inconsistent (and if power is to be added the >corresponding augmented operator should be added, too). This seems pretty trivial. It follows the rule a OP= b <==> a = a OP b (except for side effects) just fine, which is good enough for me. >Also , by your method >(++a pow b) == ++(a pow b) >and >(a pow b++) == (a pow (b++)) >are how groupings would be done. This does not look intuitive at all. Of course not. Neither does a+b / c+d You would write these (if you ever did) as ++ a*^b /* illegal */ or (++a)*^b and a *^ b++ . I would never try to guess intuitively how "*^" interacted with "++"/"--" without looking it up in the standard. Even then, I would add parens since this would be such an unusual situation. The expression -x*^2 + 5 is an entirely different (and far more important) matter. -- || Tom Stockfisch, UCSD Chemistry tps@chem.ucsd.edu