This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: call-with-dynamic-root and fluids
- To: Marius Vollmer <mvo at zagadka dot ping dot de>
- Subject: Re: call-with-dynamic-root and fluids
- From: Mikael Djurfeldt <mdj at mdj dot nada dot kth dot se>
- Date: 21 Mar 2000 22:20:11 +0100
- Cc: Mikael Djurfeldt <djurfeldt at nada dot kth dot se>, guile at sourceware dot cygnus dot com
- Cc: djurfeldt at nada dot kth dot se
- References: <E12XOrj-0007s7-00@mdj.nada.kth.se> <877lewgllm.fsf@zagadka.ping.de>
Marius Vollmer <mvo@zagadka.ping.de> writes:
> I use it with the Gtk+ bindings, when the Gtk side wants to invoke a
> Scheme callback. I wanted to make absolutely sure that control
> returns to Gtk in a way that it doesn't get confused, i.e. just like C
> guarantees it. I don't want the Scheme callback to be able to capture
> a continuation and mess up Gtk later.
Yes, this is actually the only real need I can think of myself right
now: We actually really need to be able to call callbacks from C under
a unique dynamic root.
(And, of course, we still need to use this mechanism internally, since
different threads mustn't call eachother's continuations.)
So my suggestion is:
Remove `call-with-dynamic-root' from the Scheme interface, but keep it
in the C API.
It could have a new name, e.g., scm_apply_callback, and we might
introduce some support for convenient error handling...
> What I don't like about dynamic roots is that they walk up and down
> the dynamic wind chain. For root local storage, we now have fluids
> and thus don't need to use dynamic-wind to maintain some form of
> dynamic binding between roots. I think each root can have its own
> wind chain.
The current dynamic roots *have* their own wind chain. What do you
mean by "walk up and down"? What currently happens is that since
they have a dynwind chain of their own, call-with-dynamic-root
begins by winding itself out of the caller's dynamic context, in
order to be able to start a new chain.
> What I really want from dynamic roots is, as you said, being able to
> seal off some Scheme computation so that it returns exactly once, and
> in a strictly nested fashion with respect to other sealed
> computations. If we have a meachinsm for that, and let threads do the
> rest that dynamic roots do now, I would welcome that.
Yes, I'd like dynamic roots to be only that: making a computation
return once and preventing anyone outside to call its continuations.
But this also means that dynamic roots *don't* have a wind chain of
their own (they really don't need it actually) and that fluids are per
thread, not per root.
I think we should make threads as light as we can. If a computation
needs a new set of fluid values, it can surround itself with a
suitable fluid-let.
Does this still sound reasonable?