Mark H Weaver <m...@netris.org> writes: > David Kastrup <d...@gnu.org> writes: > >> Andy Wingo <wi...@pobox.com> writes: >> >>> On Sun 04 Mar 2012 13:01, David Kastrup <d...@gnu.org> writes: >>> >>>> The global symbol space is a different identity space than heap >>>> equality, and it never gets garbage collected: the lifetime of a >>>> gensym is eternal. >>> >>> This is not true in Guile, where symbols can be garbage collected. >> >> The symbol name is not garbage collected. That is the difference >> between gensym and make-symbol. > > Integers are plentiful and cheap.
We are not talking about an integer generated statically here. We are talking about integers getting burned through every time a control structure is being used. Not at compilation time, but at runtime. And with today's computers, executing a loop often enough that the integers don't fit into a single Scheme cell anymore and stop being cheap is not really an extraordinary event. > Anyway, there's a well-known "Efficient Gensym Hack" where gensyms are > given names lazily. We haven't yet implemented that in Guile, but I > hope to add it before 2.2. With that optimization, if you never ask > for the name of a gensym (e.g. by printing it) then it is never > assigned a name or even a number. That would help. > Also, in Guile 2, prompt tags need not be symbols. Anything that can > be compared with 'eq?' will work. I suppose there is no compelling technical reason why this could not be made to also work with catch/throw, right? Being able to use something like (list #f) instead of gensym would seriously reduce the cost, both felt as well as actual. -- David Kastrup