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

Order of evaluation in PUSH (& PUSHNEW)

    Date: Wed, 20 May 87 13:57:56 -0700
    From: peck@Sun.COM

     In the form: (push (ref1) (car (ref2)))
    It is unclear whether (ref1) should be evaluated before (ref2). 

The intention of the two paragraphs on page 99

  Other macros that manipulate generalized variables include ... push ....
    Macros that manipulate generalized variables must guarantee...
  subforms of generalized-variable references are evaluated ...
  in exactly the same order as they appear in the *source* program.

was to require (ref1) to be evaluated before (ref2).  If some
implementations fail to follow this, that's evidence that this part
of the specification is not considered universally important, but
I don't think it changes the language.

I hadn't realized until I read your message that the book is actually
ambiguous (here as in so many other places).  The quoted paragraphs could
be taken to restrict order of evaluation only of the subforms of
(car (ref2)), not all of the subforms of the push form.  I'm sure
this weaker interpretation was not what was intended, and the discussion
of (setf reference value) later on the same page supports that,
since value is not a subform of a generalized-variable reference.

I personally think it's pretty dangerous for order of evaluation to
be unspecified and implementation-dependent, so I would prefer to
leave the language the way I claim it was intended to be, and as part
of the standardization process write a less ambiguous specification.