The GLib type system supports the creation and invocation of “closures”,
objects which can be invoked like procedures. Its infrastructure allows one to
pass a Scheme function to C, and have C call into Scheme, and vice versa. In
<gclosure> holds a Scheme procedure, the
<gtype> of its
return value, and a list of the
<gtype>'s of its arguments. Closures can
be invoked with
However since on the C level, closures do not carry a description of their argument and return types, when we invoke a closure we have to be very explicit about the types involved. For example:
(gclosure-invoke (make <gclosure> #:return-type <gint> #:param-types (list <gulong>) #:func (lambda (x) (* x x))) <gulong> (scm->gvalue <gulong> 10)) ⇒ 100
The Scheme representation of a GLib closure: a typed procedure object that can be passed to other languages.
Invoke a closure.
<gclosure>in GLib's abstraction for a callable object. This abstraction carries no type information, so the caller must supply all arguments as typed <gvalue> instances, which may be obtained by the scheme procedure,
As you can see, this is a low-level function. In fact, it is not used internally by the