This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++ -> guile threading



On Mon, 10 May 1999, Greg Harvey wrote:

> Peter Amstutz <tetron@student.umass.edu> writes:
> 
> > I was just playing with modules and I'm really confused as to how they
> > work, and I've been pouring over the ice-9 scheme source for the module
> > system for a while.  Are there any documents or example code showing how
> > to use modules to restrict certain pieces of code while still allowing
> > others to work?  I looks like what I'll be doing is having a bit of master
> > scheme code taking code snippits and then creating scheme threads to
> > execute said snippts... however the controlling thread-creating thread has
> > to have some access to stuff that the spawned off new threads
> > don't...
> 
> What you want to do is modify the snippets, so that they run like:
> 
> (begin
>         (define-module (restricted-module))
>         code...)
> 
> (I have no idea about threads stuff ;)

$ guile
guile> (make-thread (lambda () (define-module (restricted-module))
(display "foo")))
#<thread 806f778>
guile> foo
... 
... 
... (current-module)
#<directory restricted-module 40173650>
guile> 

ok, OUTSIDE the (lambda) expression I am in restricted-module.  The
problem is, this changes the module for the global environment.  How do I
get BACK to the main module environment?

Also, is there a way to create an "template" module once and then create
copies for each seperate bit of user code?  Then they can create "global"
variables that don't actually interfer with the outside world...

i.e.

(begin
	(get-some-code)
	(make-thread (lambda (define-module (iron-box)) (do-the-code))
)

but I'd like it that if one bit of code say (define bar 42) and another
says (set! bar 69) they wouldn't conflict...

           ------------------ Peter Amstutz --------------------
           -------------- tetron@student.umass.edu -------------
           ------- http://www-unix.oit.umass.edu/~tetron -------
           -----------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]