Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!spool.mu.edu!uwm.edu!linac!att!ucbvax!bloom-beacon!dont-send-mail-to-path-lines From: daniel@mojave.stanford.EDU (Daniel Weise) Newsgroups: comp.lang.scheme Subject: Order of evaluation (was Re: evaluating () should be an error Message-ID: <9103271633.AA26563@mojave.Stanford.EDU> Date: 27 Mar 91 16:33:06 GMT Article-I.D.: mojave.9103271633.AA26563 References: <1991Mar26.224805.23381@cs.ubc.ca> Sender: tytso@athena.mit.edu (Theodore Y. Ts'o) Organization: The Internet Lines: 40 As an example, suppose that we want to evaluate (baz (foo 1) 2 3 (+ 4 (bar 5))) on a machine which has four available registers. If the language insists we evaluate from left to right, then about the best we can do is load r0,1 call foo ;; Assume args are passed in lowest numbered regs. load r1,2 load r2,3 load r3,4 store r0,temp ;; Register spill. load r0,5 call bar add r0,4 ;; Very smart compiler notices it can cheat here. load r4,r0 ;; Assume result is returned in r0. load r0,temp call baz If, on the other hand, the compiler is free to evaluate arguments in any order, it can generate load r0,5 call bar load r3,r0 load r0,1 call foo load r1,2 load r2,3 call baz Um, you are restricting your compiler far too much. If left to right order of evaluation were mandated, the compiler would merely have to give the illusion of doing things left to right. It doesn't have to do them left to right if the programmer can't tell. In this case, the loads of constants could be performed evaluating the other arguments. Daniel