Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!orchid!clyde!rutgers!seismo!ut-sally!ut-ngp!infotel!pollux!bobkat!m5d From: m5d@bobkat.UUCP Newsgroups: comp.lang.c Subject: Re: Unary plus (and wysiwyg order or evaluation) Message-ID: <875@bobkat.UUCP> Date: Tue, 14-Apr-87 09:22:22 EST Article-I.D.: bobkat.875 Posted: Tue Apr 14 09:22:22 1987 Date-Received: Sat, 18-Apr-87 00:52:40 EST References: <6772@brl-adm.ARPA> <803@viper.UUCP> <752@rtech.UUCP> <348@zuring.mcvax.cwi.nl> Reply-To: m5d@bobkat.UUCP (Mike McNally (Man Insane)) Organization: Digital Lynx, Inc; Dallas, TX Lines: 56 In article <348@zuring.mcvax.cwi.nl> dik@zuring.UUCP (Dik T. Winter) writes: >In article <752@rtech.UUCP> jas@rtech.UUCP (Jim Shankland) writes: > > 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. >I may be dense, but I do not understand. If I write a + (b + c) the >parenthesis are just there to affect precedence, the second + has now higher >precedence than the first. >-- >dik t. winter, cwi, amsterdam, nederland I think that the best way to view the parentheses question is to re-read Mr. Shankland's assertion that the parentheses dictate the shape of the parse tree. Most (all) reorganizations of the expression happen in the parse tree (or in a reconstructed parse tree or graph). For example, given the tree + /* a + (b + c) , or a + b + c maybe */ a + b c the code generator may decide "gee, if I did this addition differently, I could save a register!" + mov a, r0 a + ==> mov b, r1 b c add c, r1 add r1, r0 + mov a, r0 + c ==> add b, r0 a b add c, r0 Of course, if the original expression were a * (b + c), no rearrangement could be made: * a + b c (unless the value of `a' were known to be a power of two or something, and the machine has some fancy "load-and-scale" instruction, in which case the compiler might distribute the multiply.) Anyway, I still say that while I appreciate the importance of controlling round-off and "dissappearing value" errors, I worry about it about as much as I worry about catching smallpox. I honestly have never been in such a situation, and I suspect that lots of people writing system software are in the same boat. -- Mike McNally, mercifully employed at Digital Lynx --- Where Plano Road the Mighty Flood of Forest Lane doth meet, And Garland fair, whose perfumed air flows soft about my feet... uucp: {texsun,killer,infotel}!pollux!bobkat!m5d (214) 238-7474