[plt-scheme] What's the best thing for a distinct handle?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Mar 19 01:06:38 EDT 2007

At Sun, 18 Mar 2007 21:40:42 -0700, Derick Eddington wrote:
> I'm using distinct values, compared using eq?, as handles (because
> they're unforgable and I can control who gets them).  I'm wondering what
> is the best type of MzScheme value to use for this.  I figure whatever
> would use the least memory is the best, so what type of MzScheme value,
> that can be used for this, uses the least memory?  A box of `null'?  A
> new empty string?  A new empty vector?

A box containing `null' would be the smallest, as far as I can tell.

I usually use a gensym, because it seems cleanest, but that's not the
smallest.

A symbol with up to three ASCII characters, as produced by
`string->uninterned-symbol', is the same size as a pair, and probably
less work for the GC to manage than either a pair or a box (since a
symbol is atomic). Using a symbol with particular characters also has
the advantage that it's more recognizable if it somehow leaks.

Matthew



Posted on the users mailing list.