[plt-scheme] How to make unit functors?

From: Robby Findler (robby at cs.uchicago.edu)
Date: Wed May 28 18:19:18 EDT 2003

At Wed, 28 May 2003 16:15:02 -0600, Matthew Flatt wrote:
> At Wed, 28 May 2003 16:32:15 -0500, Robby Findler wrote:
> > Actually, this seems bad (or maybe just confusing?) -- it means that I
> > have to save not only the hash-code for an object; I also have to save
> > the object itself to ensure the hash-code doesn't change. Maybe this is
> > only really confusing for symbols?
> 
> Can you give an example where an eq-hash-code is useful without its
> object? (Normally, you'd use a hash code to find the place in a data
> structure where the value is stored.)

Say that I'm implementing a finite mapping data structure that claims
to map all values, but only creates the actual entries lazily (ie, when
they are looked up or changed or something like that). If you ask me
for 'l many times, but I only keep the hash code for 'l in my data
structure, you may get different entries in the table at different
times, as the symbol table is gc'd. In some sense, the hash-code is a
ptr to 'l that the gc forgets about.

Robby


Posted on the users mailing list.