GNU bug report logs -
#76132
Clojure-style auto-gensyms for macros
Previous Next
Reported by: Tassilo Horn <tsdh <at> gnu.org>
Date: Fri, 7 Feb 2025 21:13:02 UTC
Severity: wishlist
Tags: patch
Done: Tassilo Horn <tsdh <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Richard Stallman <rms <at> gnu.org> writes:
Hi Richard,
> [[[ To any NSA and FBI agents reading my email: please consider ]]]
> [[[ whether defending the US Constitution against all enemies, ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> > (defmacro my-foo (exp)
> > (with-uninterned-symbols
> > `(let ((x$ 6))
> > (+ x$ ,exp))))
>
> with-uninterned-symbols does not seem to exist in my checkout.
> Is it new? Proposed?
Yes, I've proposed it but as it stands, it's already declined. That's
totally acceptable for me given the details of eager macro expansion
Stefan M. explained to me.
> I can guess from the example what it does. It is terribly un-Lispy.
> Let's use this syntax instead:
>
> (with-uninterned-symbols (x)
> `(let ((,x 6))
> (+ ,x ,exp)))
>
> It adds just one list of variables to the overall syntactic complexity
> of the construct when used, and it adds nothing to the syntax of Lipp.
>
> We could use the name `with-gensyms', a shorter name.
That's already available, named cl-with-gensyms and defined in
cl-macs.el. But truth to be told, that exhibits the very same problem
that my proposed macro also has, i.e., that
(equal (macroexpand '(cl-with-gensyms (x)
`(+ ,x ,x)))
(macroexpand '(cl-with-gensyms (x)
`(+ ,x ,x))))
;;=> t
meaning that every expansion uses the very same uninterned symbol x, not
one unique symbol x per expansion. As Stefan explained, that can lead
to problems in certain (honestly quite uncommon) corner-cases.
Bye,
Tassilo
This bug report was last modified 147 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.