From: <Joe...@t-...> - 2017-12-20 18:16:18
|
Hi again, Having fun, here's the version with the need for most gensyms removed: (defmacro lazy-let1 ((var) &body body) (let ((shadow (gensym (symbol-name var)))) `(let ((,shadow 'unbound)) (flet ((,shadow () (if (eq ,shadow 'unbound) ,var ,shadow)) ((setf ,shadow) (,var) (setf ,shadow ,var))) (symbol-macrolet ((,var (,shadow))) .,body))))) (setf ,shadow) is indeed defined as (setf ,shadow) - scoping rules! 'unbound should be replaced by the usual unique CONS trick, and perhaps #1#... This is just for the fun, I don't like this macro because of the run-time check. Actually, it has huge costs in clisp - try out DISASSEMBLE - as the closures are not inlined. Regards, Jörg |