[plt-scheme] Question about bindings...

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Jul 9 16:57:40 EDT 2002

On Jul  9, Aaron Leung wrote:
> I've sometimes heard people talk about creating 'bindings' for GTk
> or OpenGL or some other similar thing.  I have a vague idea what
> this means, but can someone explain in a little more detail?

The process of linking GTk or whatever into a .so file that will make
Scheme-accessible functions that will call the library functions.

For example, putting this in a C file:

  static Scheme_Object *s_XmmsPlay(int argc, Scheme_Object **argv)
    xmms_remote_play(XMMS_SESSION); return scheme_void;
  Scheme_Object *scheme_reload(Scheme_Env *env)
                      scheme_make_prim_w_arity(s_XmmsPlay, "play", 0, 0),

and compiling it as an MzScheme extension, linking the xmmsctrl
library in, will create a Scheme `binding' for the xmmsctrl `play'

Using my ffi thing, you could substitute that whole process with

  (define (xmms:play)
    (ffi-call (ffi-obj (ffi-lib "libxmms.so") "xmms_remote_play")
              '(0) '(int) 'void))

but for some reason people doesn't seem to be excited about this as I

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.