Skip to content

Commit

Permalink
Add binding for item to ensure it is evaluated before place
Browse files Browse the repository at this point in the history
  • Loading branch information
yitzchak committed Jun 4, 2024
1 parent 5b0c32d commit 74b5c6f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Code/pushnew.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@
(if (and test-supplied-p test-not-supplied-p)
(progn (warn 'warn-both-test-and-test-not-given)
`(error 'both-test-and-test-not-given))
(multiple-value-bind (vars vals store-vars writer-form reader-form)
(get-setf-expansion place environment)
`(let (,@(mapcar #'list vars vals))
(let ((,(car store-vars)
(adjoin ,item ,reader-form ,@rest)))
(let ((item-var (gensym)))
(multiple-value-bind (vars vals store-vars writer-form reader-form)
(get-setf-expansion place environment)
`(let* ((,item-var ,item)
,@(mapcar #'list vars vals)
(,(car store-vars)
(adjoin ,item-var ,reader-form ,@rest)))
,writer-form)))))

(setf (documentation 'pushnew 'function)
Expand Down

0 comments on commit 74b5c6f

Please sign in to comment.