Re: Weakness of "non-object" types John Cowan 04 Dec 2015 15:12 UTC

Taylan Ulrich Bayırlı/Kammer scripsit:

> Booleans, characters, numbers, symbols, and the empty list object are
> never stored weakly or ephemerally.

I think it's bad to include numbers in this list.  The whole point of
non-strong hashtables is to allow things to be garbage collected that
you don't care about any more.  Booleans, characters, and the empty list
are in practice represented either by immediates or by singletons, and in
many Schemes, symbols are the values in a hidden strong hash table that
maps strings to symbols.  (For standards purposes, uninterned symbols
don't count as symbols).  So they will never be reclaimed anyway.

But numbers are potentially unbounded in size, specifically bignums
and ratnums or rectnums made from bignums.  Not allowing them to be
held weakly means that they cannot easily be reclaimed when stored as
inaccessible values in a hash table.  That leads to the memory exhaustion
that non-strong hash tables are designed to prevent.

Given that, I question the utility of pointing all this out, since it
is an implementation detail for the types other than numbers, and is
broken for numbers.

> The implementation will GC a symbol when there are no strong references
> left to it.

Not necessarily, no.

--
John Cowan          http://www.ccil.org/~cowan        xxxxxx@ccil.org
They tried to pierce your heart with a Morgul-knife that remains in
the wound.  If they had succeeded, you would become a wraith under the
domination of the Dark Lord.         --Gandalf