Created
July 15, 2010 12:30
-
-
Save bowbow99/476876 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; setf'able な PLACE を一時的に変更して BODY を評価する | |
(defmacro letf (bindings &body body) | |
(let ((originals (mapcar (lambda (x) (gensym)) bindings))) | |
`(let (,@(mapcar (lambda (sym x) `(,sym ,(car x))) | |
originals | |
bindings)) | |
(unwind-protect | |
(progn | |
(setf ,@(mapcan #'identity bindings)) | |
,@body) | |
(setf ,@(mapcan (lambda (b o) | |
`(,(car b) ,o)) | |
bindings | |
originals)))))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
let と let* 的な意味で psetf の方がいいかも
let みたいに値を省略してカッコ外すのはできない。下の (ACC-2 X) が PLACE なのか (PLACE VALUE) なのか判断できないんで。