Hi Shiro,
On 2025-01-24 01:20 -1000, Shiro Kawai wrote:
> Gauche does have gensym that returns uninterned symbols, but they're used
> only to support legacy macros. (I use gensym as a handy way to get new
> symbols whose name doesn't matter, aside from macros, but for that purpose
> it can be interned).
I’m very sorry for overlooking Gauche. I’ve updated the table:
https://github.com/Zipheir/srfi-258/commit/de9800122b0825b609ad0b913a2edbcf5a035e2c
As you say, one use for gensym / generate-uninterned-symbol is
for naming, e.g. when emitting S-expression representations of data
structures. But indeed, a procedure that generates an interned symbol
with a unique name is all you really need for this.
I struggled with the question of whether to write a SRFI for uninterned
symbols, or a very general one specifying only gensym, a procedure
that returns a symbol that is very likely to be unique. In the end,
I decided that describing a minimal gensym wouldn’t be very useful,
especially when uniqueness can’t be guaranteed across implementations.
Uninterned symbols, however, are quite consistent across the many
implementations that provide them.
> I also don't quite understand that the uninterned symbols are
> self-quoting. One possible advantage of uninterned symbols over
> identifiers is that the macro output using uninterned symbols is, in fact,
> able to be read back. For example, in Gauche:
>
> (let ((v (gensym)))
> (write-shared `(let ((,v 1)) (+ ,v ,v))))
> => prints (let ((#0=#:G179 1)) (+ #0# #0#))
>
> (let ((#0=#:G179 1)) (+ #0# #0#))
> => 2
>
> Does "self-quoting" nature prohibit this kind of use case?
Good point—it does, since :|G179| would be read in as a symbol.
Self-quotation is probably a mistake, now that I look at it more
carefully. The lexical syntax is based on ChezScheme’s notation, but,
in ChezScheme, #:foo is an identifier, not a symbol. (For some reason I
thought Chez’s gensyms were self-quoting.) I will probably remove
self-quotation in the next draft.
--
Wolfgang Corcoran-Mathe <xxxxxx@sigwinch.xyz>