2 ms·
You don't need hygiene (WITH-GENSYMS and so on) in Common Lisp macros in two situations: when you do not introduce any new bindings and when you only introduce
by phoe-krk 5y ago
You don't need hygiene (WITH-GENSYMS and so on) in Common Lisp macros in two situations: when you do not introduce any new bindings and when you only introduce bindings that the user is allowed to name themself. That's why the following code:
(with-open-file (my-super-stream #p"/tmp/foo" ...) ...)
Can expand into something like this:
(let ((my-super-stream (open #p"/tmp/foo" ...))) ...)
Note that the variable name, MY-SUPER-STREAM, is provided by the user, so if there is any variable capture/shadowing present then it is of the user's own making and they can reap the benefits and costs of doing so.
- gmfawcett 5y agoI agree, and I missed the fact that kazinator's code was introducing new variables. I'm always happy to be wrong in public for didactic purposes. :)