address@hidden (Ludovic Courtès) writes:
‘gensym’ returns interned symbols, but the algorithm to determine the
new symbol is simplistic and predictable.
Thus, one can arrange to produce a symbol before ‘gensym’ does,
leading
‘gensym’ to return a symbol that’s not fresh (in terms of ‘eq?’), as
is
the case with the second call to ‘gensym’ here:
address@hidden writes:
I agree, this goes against the main assumption people have about
gensym. I was able to reproduce the bug.
Here's a patch to libguile/symbol.c which fixes this behavior by
incrementing the gensym counter in a loop until it creates a fresh
symbol.
I've considered this idea in the past, but it only avoids collisions
with symbols that have been interned before the gensym. It does not
avoid collisions with symbols interned *after* the gensym. Obviously,
there's no way to avoid such collisions.