From: Douglas K. <do...@go...> - 2013-10-30 06:30:35
|
A closure created while in the process of binding sequentially will, when applied, accidentally see the state of the environment after further modifications. I have a fix for this, but it's not a patch; it's a piece in a substantial rewrite of eval. The compiler has the semantics right, for comparison's sake. (defvar *stash*) (defun save-it (f) (setq *stash* f) 'whatever) (let ((z 'zee) (y 'y) (x 92)) (let* ((baz (save-it (lambda (what) (print (list what x y z))))) (mum (funcall *stash* :after-binding-baz)) (y 'new-y) (z (progn (funcall *stash* :after-binding-y) 'new-z)) (x (progn (funcall *stash* :after-binding-z) 'new-x))) (funcall *stash* :in-body) (values))) prints (:AFTER-BINDING-BAZ 92 Y ZEE) (:AFTER-BINDING-Y 92 NEW-Y ZEE) (:AFTER-BINDING-Z 92 NEW-Y NEW-Z) (:IN-BODY NEW-X NEW-Y NEW-Z) |