[plt-scheme] Regarding symbols

From: Øyvin Halfdan Thuv (oyvinht-scheme at orakel.ntnu.no)
Date: Sun May 16 05:35:51 EDT 2004

Neil W. Van Dyke, 
> > - how do I intern a symbol?
> > 
> > (let ((hashname (format "HASH-~A" hashnumber)))
> >    (set! (string->symbol hashname) (make-hash-table)))
> 
> You are mapping "hashnumber" to hash tables?  I wouldn't try to use
> environment bindings for this like you do in CL.  I would instead make a
> hash table, keyed on "hashnumber", of hash tables.

Well probably a more elegant solution, ince I don't know yet how to
use packages in Scheme. Seems namespace-defined? did exactly what I wanted,
btw.

> Search for "make-hash-table" in the Help Desk.  It's in the MzScheme manual.

Nice! I'm starting to like this IDE. Actually I find it better than some 
commercial ones. I think I hav spent less time creating a gui with PLT than
I did figuring out how to create a (working) gui with AllegroCL-enterprises 
gui-builder. And this one is platform independent. Great!

The code also is a lot cleaner and maybe 10% shorter.

> > - can I use strings as keys in the hash-table, or is it better
> > (faster) to use symbols (e.g. by using string->symbol). There are
> > quite a few words, say 20000-40000 depending on the language.
> 
> I will let Matthew Flatt answer that one.

Well, thinking about this, when using symbols as keys, I suppose I'm
actually dealing with adresses and not some computed value. So it should
be fast. However, each symbol might use some additional memory (I don't
know how much). For, say, 30 000 symbols it's a few bytes...

-- 
Øyvin


Posted on the users mailing list.