[gambit-list] How to pass a procedure to a nonnull-function?

Vok Vojwo ceving at gmail.com
Thu Nov 3 08:58:40 EDT 2011

This version works:

;; Local Variables:
;; compile-command: "gsc -exe ffi-hello-2.scm"
;; End:

(c-declare #<<end-of-c-declare

typedef void(*func_t)(void);

void call_func (func_t func)


(c-define-type func_t (nonnull-function () void))

(define call-func
  (c-lambda (func_t) void "call_func"))

(c-define (proc) () void "func" ""
  (display "Hello, World!"))

(write (procedure? proc))

(call-func proc)

But it is of limited use if it comes to Gtk callbacks. If one
dynamically creates Gtk widgets it is necessary to be able to assign
them callbacks. If the definition of the callback must be done on the
Scheme top level and always requires a C name the whole code becomes
quite static.

Gtk provides some infrastructure for callbacks called marshaller.
Would it be possible to use that to write a gtk-lambda similar to
c-define, which can be used to create callbacks for Gtk but without
the limitations of c-define?

More information about the Gambit-list mailing list