This is the mail archive of the guile@sourceware.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: call-with-dynamic-root and fluids


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?

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