Skip to content

Commit

Permalink
Call GET-SETF-EXPANSION rather than the equivalent environment function.
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-strandh committed Sep 27, 2020
1 parent 33aac44 commit 99aee07
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions Code/Data-and-control-flow-Clostrum/setf-defmacro.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@

(defmacro setf (&whole form &environment env place new-value-form &rest more-pairs)
(cond ((null more-pairs)
(let* ((global-env (sicl-environment:global-environment env))
(client (sicl-environment:client global-env)))
(multiple-value-bind (variables
values
store-variables
writer-form
reader-form)
(sicl-environment:get-setf-expansion client env place)
(declare (ignore reader-form))
`(let* ,(mapcar #'list variables values)
;; Optimize a bit when there is only one store variable.
,(if (= 1 (length store-variables))
`(let ((,(first store-variables) ,new-value-form))
,writer-form)
`(multiple-value-bind ,store-variables
,new-value-form
,writer-form))))))
(multiple-value-bind (variables
values
store-variables
writer-form
reader-form)
(get-setf-expansion place env)
(declare (ignore reader-form))
`(let* ,(mapcar #'list variables values)
;; Optimize a bit when there is only one store variable.
,(if (= 1 (length store-variables))
`(let ((,(first store-variables) ,new-value-form))
,writer-form)
`(multiple-value-bind ,store-variables
,new-value-form
,writer-form)))))
((not (null (cdr more-pairs)))
`(progn (setf ,place ,new-value-form)
(setf ,@more-pairs)))
Expand Down

0 comments on commit 99aee07

Please sign in to comment.