[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: hash tables and GC



I may be missing something, but this doesn't look like very complex 
semantic issue to me.  [Implementation is another matter.]  The conditions
under which a hash table key is accessible ONLY via maphash were, I
believe correctly, spelled out in my earlier message.  If those conditions
are met, and the program in fact does not do maphash's on the array,
AND (as I neglected to notice earlier) the program does NOT apply
HASH-TABLE-COUNT to the array, then it is SAFE to remove the entry for the
key from the hash table.  [SAFE == the program cannot possibly tell that
it has happened.]


As was correctly pointed out, if hash table EQUALity is defined, then the
safety conditions mentioned are no longer sufficient.

In general, I think if a programmer authorizes (whether through
declarations, or extra arguments to a function like MAKE-HASH-TABLE), some
potentially unsafe optimization by the implementation (such as the garbage
collector removing hash table entries), it is VERY desirable to identify
sufficient conditions (such as no uses of maphash and no hash-table-count]
under which the optimization is SAFE and declare that "it is an error", 
if the program requesting the optimization violates those conditions.
Of course, these SUFFICIENT conditions may not be NECESSARY, so 
some programmers, like those at CORAL, may be astute enough
to write programs that violate the sufficiency conditions but are
nevertheless portable.  More power to them.  (Or maybe they can state
weaker sufficiency conditions?) But if I were just
presented with some procedural description of an optimization I can request 
and NO guidance on when it is safe (just a line that says USE WITH
CAUTION), I would be loathe to try using it at all.


Neil