[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Interpreter Sessions (Newbie)
From: |
Clinton Ebadi |
Subject: |
Re: Interpreter Sessions (Newbie) |
Date: |
Sat, 22 Feb 2003 12:53:28 -0500 |
User-agent: |
KMail/1.4.2 |
On Saturday 22 February 2003 12:03, Pedro Ortega wrote:
> 1. Given an user id, create (if it doesn't exist) or
> restore the environment (using a database or another
> persistent storage media).
You can do this with modules:
;;; (make-module size uses-list)
(define userid-module (make-module 1021 (list (resolve-module
'(guile-user)))))
Now you have a module that has access to all the symbols from guile-user (you
can add other modules to the uses-list, just use resolve-module to resolve
the module from the name).
You can then pass userid-module as the second argument to eval or you can do
things like:
(module-define! userid-module 'foo 5) ; foo now has the value 5 in
userid-module
> 2. Execute the Scheme code with the environment, in order
> to get the response string.
(eval "expression" userid-module)
Or I think you may be able to have different module set for each thread so you
could give each user their own thread and do (set-current-module
userid-module) in that thread (I'm not entirely sure because I don't use
threads).
> 4. Save the updated environment.
You can't do this right now, although I could add support for serializing
modules to my hacked together object serializer
(http://unknownlamer.org/files/temp/serialize.scm) which I will be merging
back into Guile-Web soon.
--
http://unknownlamer.org