[plt-scheme] setting a var whose name is det'ed at runtime (newb)

From: Daniel Yoo (dyoo at cs.wpi.edu)
Date: Thu Apr 26 11:25:21 EDT 2007

> (set! (get-name) (car some-list)) returns "set!: not an identifier in: 
> (get-name)".  I think this behavior is required by lexical scoping, in 
> which case, How do we set a variable whose name is dynamically 
> determined?  thanks

Are you familiar with hash tables?  They go by different names 
(dictionaries, maps, associative lists).  This data structure provides a 
container to associate a key to a value: the key can be calculated at 
runtime to get (or set) the corresponding value.

For example:

> (define classes (make-hash-table 'equal))
> (hash-table-put! classes "cs525f" "security")
> (hash-table-get classes "cs525f")

For more information on hash tables, see:


Posted on the users mailing list.