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: fluid-let in guile.


hjstein@bfr.co.il (Harvey J. Stein) writes:

> STk has fluid-let, which is very convenient for temporarily rebinding
> variables from the current environment.  Does Guile have such a thing?
> I found with-fluids, but it seems to be another concept entirely.

I'm not familiar with STk's fluid-let, but I think that modulo syntax
and for single-threaded programs, they are very close.  In any case,
if Stk's fluid-let is what I think, it can easily be implemented in
terms of dynamic-wind.  Please ask for details if you need them.  I
don't think we should add this implementation to Guile because it has
not the right properties with regard to threads.

Back when I decided I need something like fluids in Guile, I did a
quick survey of the available implementations of them.  I found no
clear agreement on what exactly a fluid is and so I implemented my own
ideas on the subject, which are of course slightly different from
everybody elses.

I wanted to have something like dynamic binding, but I didn't want to
mess with Scheme's syntax at all and as little with its semantics as
possible, and I wanted it to work with truly parallel threads (on a
multi-processor, say).

So I decided that my fluids would be real objects that needed to be
accessed with `fluid-ref' and `fluid-set!' and they need to be deeply
rooted in the threading engine of Guile to give them the right
semantics.  `with-fluids*' is not implemented in terms of
dynamic-wind, but only for performance reasons.