Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!news.cs.indiana.edu!hieb@heston.cs.indiana.edu From: hieb@heston.cs.indiana.edu (Robert Hieb) Newsgroups: comp.lang.scheme Subject: Re: Order of evaluation (was Re: evaluating () should be an error Message-ID: <1991Mar27.101357.20383@news.cs.indiana.edu> Date: 27 Mar 91 15:13:39 GMT Article-I.D.: news.1991Mar27.101357.20383 References: <2977@kraftbus.cs.tu-berlin.de> <1991Mar26.155905.12906@daffy.cs.wisc.edu> <1991Mar26.224805.23381@cs.ubc.ca> Organization: Computer Science, Indiana University Lines: 38 manis@cs.ubc.ca (Vincent Manis) writes: >Because it can substantially impair the ability of a compiler to produce >high-quality code. If a compiler is required to honour a particular >order of evaluation, then compiling expressions which require most of >the registers available will almost inevitably result in register >spills, which then slow the code down. Saving registers around a call to an unknown procedure is not likely to substantially slow down code, due to the call overhead. In practice, I don't think an optimizing compiler is going to be significantly handicapped. The compiler can always reorder arguments it can prove are independent of evaluation order, and since these are likely to the be the simplest arguments they are likely to gain the most from such reordering. harlan@copper.ucs.indiana.edu (Pete Harlan) writes: >If I'm reading your code and come across ((foo) (a b) (c d)), I know >that the three applications are completely independent This argument is stronger, but unfortunately also of little use in practice. All you know is that the programmer PROBABLY THOUGHT that the three applications are independent. In fact they may not be, and until program is tested under all possible evaluation orders or completely annalized using all possible evaluation orders there is no way to be sure. If arguments can be evaluated in different orders on different calls (I know the formal semantics in R*S says otherwise, but that is how the game is usually played), neither approach to establishing program correctness is practical. Scheme is hiding its head in the sand with respect to argument evaluation order and unspecified return values. Arguments do get evaluated in some order and values are returned. Wishing that it weren't so is of little use to the producers and consumers of supposedly portable programs.