[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unspecified order of evaluation in Scheme



The meaning intended was that the order of evaluation may be chosen
differently for each *dynamic* procedure call.  Thus an optimizing
compiler might choose a different order of evaluation each time it
inlines code that contains the static call, and an interpreter might
keep programmers honest by choosing the order randomly for each dynamic
call.

The reason the order of evaluation is constrained to be consistent
with a sequential order of evaluation is that people didn't want to
have to specify a sequential order for all side effects or else put
critical sections around them.  For example, if a file called
"random_numbers" contains

    123 456

then people wanted

    (call-with-input-file
     "random_numbers"
     (lambda (p)
       (list (read p) (read p))))

to evaluate nondeterministically to (123 456) or to (456 123), but not
to (13 2456) or to (23456 123).

William Clinger