Re: Support for C Callbacks
you can pass a module to another, but
generally, and almost invariably when there is more than
one thing going on, we replace a callback structure
by a process structure: the callback action is replaced by a message
send on a channel. sometimes the initiator provides the channel;
sometimes the channel is returned from an initialisation
function in the called module.
see http://www.cs.bell-labs.com/cm/cs/doc/89/1-a.ps.gz
for a discussion of this approach to building a programming interface to a window system,
in contrast to the usual event-driven style (with callbacks, cf. X11).
in fact, the current Inferno window system was modelled on that one.
for a built-in module, it is probably easiest to
have the application that is interacting with the built-in module
provide an appropriate channel itself.
see Tk->namechan for example:
namechan: fn(t: ref Toplevel, c: chan of string, n: string): string;
when something happens, a message is sent to a Limbo application receiving on channel c;
alternatively, to show that giving a channel a textual name isn't necessary,
the select function of Prefab->Compound:
select: fn(comp: self ref Compound, elem: ref Element, i: int, c: chan of int): (int, int, ref Element);
which reads remote control selections from channel c
until the user chosen something from the menu represented by the Compound,
and select then returns the index.