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

Bug #1452539 reported by Douglas Katzman
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
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))))
  (SB-KERNEL:%RPLACA #:LIST538 #:NEW539))

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)
Changed in sbcl:
assignee: nobody → Douglas Katzman (dougk)
Douglas Katzman (dougk)
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  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.