[racket] Creating ids from symbols

From: Mark Carter (mcturra2000 at yahoo.co.uk)
Date: Fri Aug 5 03:59:09 EDT 2011

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110805/c02116ef/attachment.html>

Posted on the users mailing list.