This is the mail archive of the
guile@cygnus.com
mailing list for the Guile project.
Re: c++ -> guile threading
- To: tetron@student.umass.edu
- Subject: Re: c++ -> guile threading
- From: Greg Harvey <Greg.Harvey@thezone.net>
- Date: 11 May 1999 20:10:38 -0230
- Cc: guile@cygnus.com
- Original-Sender: Greg.Harvey@thezone.net
- References: <Pine.LNX.4.00.9905111720260.2503-100000@mir.static.net>
Peter Amstutz <tetron@student.umass.edu> writes:
> On Tue, 11 May 1999, Greg Harvey wrote:
>
> > > > (I have no idea about threads stuff ;)
> >
> > I'd like to stress that once again :). I was thinking that the current
> > module would (and probably should) be local to the thread, but this is
> > not the case. Trying to figure out how to do it does make for a nice
> > little mind bending problem ;), but I think the only way you could do
> > this would be to make the various module variables into fluids, or
> > something similar.
Doh, that's probably not even necessary (there's something to be said for
documentation *sigh*). In any case, you can use save-module-excursion,
like this:
guile> (make-thread (lambda ()
(save-module-excursion
(lambda ()
(define-module (restricted))
(display (current-module))))))
#<thread 805d528>
guile> #<directory restricted 401b4d08>
guile> (current-module)
#<directory guile-user 401c6fc8>
Unfortunately, it's not quite there for what this needs:
guile> (make-thread (lambda () (save-module-excursion
(lambda () (define-module (restricted)) (let loop ((n 1)) (loop (+ n 1)))))))
#<thread 805d528>
guile> (current-module)
#<directory restricted 401b4b00>
There probably is a way to make this work, tho.
--
Greg