[racket] Creating ids from symbols

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Aug 5 07:19:10 EDT 2011

The `namespace-set-variable-value!' function might work.

At Fri, 5 Aug 2011 08:59:09 +0100 (BST), Mark Carter wrote:
> Is it possible to set an id from a symbol, call it set-symbol? For example, I 
> might type
> (define life -12)
> 
> (set-symbol 'life 42)
> life ; => 42
> 
> The reason I want to do this is so that I can store a cache of variables to 
> disk.
> 
> The cache will contain a list of variables to be stored. So I might ultimately 
> want something like
> (define-cache a-cache "mycachefile")
> (encache a-cache foo)
> (encache a-cache bar baz)
> (set! foo 42)
> foo ; => 42
> (save-cache a-cache)
> which attempts to define the variables foo, bar and baz if they have been 
> serialized to mycachefile, and leave them as (void) 
> otherwise.



Posted on the users mailing list.