Re: The alternative proposal
Marc Nieper-WiÃkirchen 26 Jan 2025 18:42 UTC
Am So., 26. Jan. 2025 um 19:23 Uhr schrieb Shiro Kawai <xxxxxx@gmail.com>:
>
> IIRC, a random number generator is only needed for portable implementation, right? If the implementation internally provides a way to check if the name is already used, RNG isn't needed.
A native implementation would just generate a symbol object (with an
address) but without a name when (generate-symbol) is invoked. The
symbol cannot be interned, of course, because it has no name, yet.
Only when "symbol->string" is invoked, a name has to be generated. The
system will then be interned. Of course, the implementation can check
whether the generated name is already in use, but such a check would
be useless because the name has to be unguessable anyway (you can't
just take the next free name in alphabetic order, for example).
> Uninterned symbols can't be implemented portably anyway. So far I can't think of use cases of uninterned symbols that Marc's lazily-interned symbols, except one (which is also beyond RnRS): Printing the code with uninterned symbols and reading it back without the possibility of name conflict.
> It can be addressed if the implementation remembers lazily interned symbols and uses srif-10 notation to write it out.
>
> (let ((#0=#,(generate-symbol))) (+ #0# #0#))
See my point (3) why, in general, an implementation has to offer a
name for a symbol used as an identifier, whether it is interned or
not. So, all that applies to interned symbols also applies to
uninterned ones. For interned ones, it is simpler because they already
have a name (at least conceptually).