Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!ptsfa!well!msudoc!umich!jtr485 From: jtr485@umich.UUCP (Johnathan Tainter) Newsgroups: comp.lang.c Subject: Re: Unary plus (and wysiwyg order or evaluation) Message-ID: <105@umich.UUCP> Date: Wed, 15-Apr-87 01:21:00 EST Article-I.D.: umich.105 Posted: Wed Apr 15 01:21:00 1987 Date-Received: Sun, 19-Apr-87 18:06:33 EST References: <6772@brl-adm.ARPA> <803@viper.UUCP> <752@rtech.UUCP> Organization: EECS, University of Michigan Lines: 55 In article <752@rtech.UUCP>, jas@rtech.UUCP writes: > Sorry to add to a discussion that may have gone on too long; I'll be brief. > > Postings like this betray some confusion: > > > It wasn't until reading about unary '+' that i knew that C might > > disregard my parens. > > >I think parens should be followed without any micky-mousing from the compiler. > > PARENTHESES AFFECT PRECEDENCE, NOT EVALUATION ORDER. THESE ARE 2 DIFFERENT > THINGS. To put it another way, parentheses affect the shape of the parse > tree for an expression; evaluation order is an order in which the parse > tree is walked. Unary '+' does not "override" parentheses, Correct so far. > nor may a compiler > "disregard my parens." Parens have a precise and essential function, entirely > distinct from order of evaluation. Sorry, Jim. But, you are the one showing confusion here. The compiler CAN disregard parens! (K&R page 49) Unary plus exists to keep it from doing so. Unary plus does NOT alter order of evaluation, it just maintains precedence specified by the parentheses. i.e. on a simple stack machine: +(x + y) + z CANNOT generate push x; push y; push z; add; add OR push y; push x; push z; add; add OR push x; push z; push y; add; add OR push y; push z; push x; add; add OR push x; push z; add; push y; add OR push y; push z; add; push x; add OR push z; push x; add; push y; add OR push z; push y; add; push x; add but (x + y) + z can. This says nothing about whether the former is: push x; push y; add; push z; add OR push y; push x; add; push z; add OR push z; push x; push y; add; add OR push z; push y; push x; add; add --j.a.tainter > Jim Shankland