+(defmacro persistent-let (name vars &rest forms)
+ (labels ((get-vars (vars)
+ (cond ((null vars) nil)
+ (t (cons (if (consp (car vars)) (caar vars) (car vars))
+ (get-vars (cdr vars)))))))
+
+ `(let ,(cond ((functionp name)
+ (let ((old-vars (funcall name)))
+ (cond ((equal (get-vars vars) (get-vars old-vars)) old-vars)
+ (t vars))))
+ (t vars))
+ (defun ,name ()
+ ,(let ((lvars (get-vars vars)))
+ `(mapcar (lambda (x y) (list x y)) ',lvars ,(cons 'list lvars))))
+ ,@forms)))
+