Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site mit-eddie.UUCP Path: utzoo!linus!security!genrad!mit-eddie!barmar From: barmar@mit-eddie.UUCP (Barry Margolin) Newsgroups: net.lang.c Subject: Re: Must useless expressions be evaluated? Message-ID: <817@mit-eddie.UUCP> Date: Sat, 15-Oct-83 02:33:28 EDT Article-I.D.: mit-eddi.817 Posted: Sat Oct 15 02:33:28 1983 Date-Received: Sun, 16-Oct-83 10:22:30 EDT References: <317@ucbtopaz.CC.Berkeley.ARPA> Organization: MIT, Cambridge, MA Lines: 31 ether there are any side effects and whether the value of an expression is used. PL/I (or at least the Multics version) allows the programmer to give a function the "reducible" attribute. A reducible function is one which does not have any side effects and whose value is solely a function of the arguments (i.e., not global variables can affect the value). The compiler is then free to throw away excess calls, i.e. it may translate y = foo (x) + foo (x); to y = 2 * foo (x); and it may skip over reducible function calls in boolean expressions, i.e. if bool_var | foo (x) then ... is permitted to not evaluate foo (x) if bool_var is true. -- Barry Margolin ARPA: barmar@MIT-Multics UUCP: ..!genrad!mit-eddie!barmar