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

Re: Unspecified order of evaluation in Scheme



> Date: Fri, 23 Sep 94 15:14:04 -0400
> From: Jim Miller <jmiller@martigny.ai.mit.edu>
> To: wand@ccs.neu.edu
> Cc: myra@saul.cis.upenn.edu, will@ccs.neu.edu,
>         rrrs-authors@martigny.ai.mit.edu
> Subject: Unspecified order of evaluation in Scheme
> Reply-To: JMiller@martigny.ai.mit.edu

> Mitch says:
>    I would read the phrase "the operator expression and the operand expressions
>    are always evaluated with the same evaluation rules" as precluding the
>    possibility that different executions of the same procedure call have
>    different orders of evaluation.

> FWIW, I understand them differently.  I assume it means that, unlike
> other dialects of LISP, the operator and operand expressions have the
> same (semantic?) evaluation funcition.  That is, Scheme does *not*
> have separate function and variable name spaces (for example).

Yes, you are probably right about the intended meaning of this sentence.  I
had entirely forgotten this bit of history.  But it says "always evaluated",
which suggests some temporal invariance.  If your meaning was intended, the
phrase should simply have been "evaluated". 

> I've also always assumed that one could replace any call to an n-ary
> function (i.e. n+1 evaluable positions in the call) with a hairy
> expression involving a call to (RANDOM (FACT (+ N 1)) to decide on the
> evaluation order ... we've joked about doing exactly this in the MIT
> Scheme interpreter since at least 1982.  [The compiler had to be fast,
> so we couldn't do it there :-)]

You may be right, but looking at the text I'm still not sure.

The interpretation of the text is made more difficult because it refers to
"evaluation rules", and a quick grep indicates that this is the only place in
the document that uses this terminology.

But consider the sentence "The order of evaluation may be chosen differently
for each procedure call."  Is a "procedure call" a syntactic entity, a dynamic
entity, or something in between?  If a procedure call is a dynamic entity,
then Jim's proposal seems correct.  On the other hand, we are in a section
that defines a syntactic construct called a "procedure call", so the naive
interpretation would be that it refers to the syntactic entity.  So it is
possible to interpret the text as saying that the order of evaluation may be
different for each syntactic call in the program, and therefore must be the
same for each dynamic event that corresponds to that syntactic call.

So I'm confused.  I'm going to be quite now and wait for the real Talmudists
to arrive.

--Mitch