eq and hashing (was Re: [plt-scheme] How to make unit functors?)

From: plt scheme proxy for Felix (pltscheme at pnkfx.org)
Date: Thu May 29 13:42:01 EDT 2003

On Thursday, May 29, 2003, at 01:21 PM, John Clements wrote:
>
> Just to have the question out there:  how bad would it be never to 
> collect (the strings representing) symbols? The up side would be that 
> this problem would go away.  The down side is that certain loops could 
> exhaust memory... but _only_ those where the loop included a 'read' or 
> equivalent. How many symbols are interned while starting up DrScheme, 
> for instance?

As another lurker coming out of the shadows here, my opinion may not 
matter much, but I disagree with this proposal.

Making symbols non-garbage-collectable would cause memory issues for 
long-lived processes, such as web-servers.  I am currently planning on 
using mzscheme as a basis for a Wiki server, but I don't want to have 
to periodically restart the server just because it can't get rid of any 
symbols that have been passed to eq-hashcode.

The undesirable behavior that Robby has described is only exposed when 
you are using eq-hashcode; it cannot be exposed with eq? alone.  
Therefore, I would suggest that any data-structure that is doing 
something like Robby's mapping is also responsible to keep a reference 
to every symbol that is inserted into it.  These references don't have 
to be accessible in any way to the client; they could just be a 
linked-list of symbols that is hidden from the accessors for the 
structure.

If I learned anything from reading Bjarne Stroustrup, its that you 
should not make people pay a significant cost for a feature that they 
are not (necessarily) using.  Making symbols (even just ones that have 
been passed at some point to eq-hashcode) is an example of such a 
feature, in my opinion.

-Felix



Posted on the users mailing list.