define-modify-macro doesn't do what CLHS 5.1.3 says

Bug #1452539 reported by Douglas Katzman on 2015-05-07
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Douglas Katzman

Bug Description

* (define-modify-macro snorkf (a &optional (color :purple)) snork)
* (macroexpand-1 '(snorkf (second (p)) (sqrt g) (compute-color)))
(LET* ((#:LIST538 (CDR (P)))
       (#:NEW539 (SNORK (CAR #:LIST538) (SQRT G) (COMPUTE-COLOR))))

The spec: "... these operators can be viewed as involving a form with the following general syntax:
 (operator preceding-form* place following-form*)
The evaluation of each such form proceeds like this:

1. Evaluate each of the preceding-forms, in left-to-right order.
2. Evaluate the subforms of the place, in the order specified by the second value of the setf expansion for that place.
3. Evaluate each of the following-forms, in left-to-right order.
4. Read the old value from place.
5. Compute the new value.
6. Store the new value into place."

So 3, 4, 5 imply delaying (CAR #:LISTnnn) until after (SQRT) and (COMPUTE):
(LET* ((#:LIST562 (CDR (P)))
       (#:G564 (SQRT G))
       (#:G565 (COMPUTE-COLOR))
       (#:NEW563 (SNORK (CAR #:LIST562) #:G564 #:G565)))
  (%RPLACA #:LIST562 #:NEW563))

CLISP and ECL do that.

Douglas Katzman (dougk) on 2015-05-07
Changed in sbcl:
assignee: nobody → Douglas Katzman (dougk)
Douglas Katzman (dougk) on 2015-05-08
Changed in sbcl:
status: New → Fix Committed
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers