[Openmcl-devel] Calling a callback & closures

David Steuber david at david-steuber.com
Sun May 1 23:26:47 PDT 2005


Hello,

I'm trying to see if I can use DEFCALLBACK to close over lexical 
variables so that when a C function calls into lisp, the correct value 
will be in the variable.  I'm not clear how closures work, so I don't 
even know if the idea is sane.  To start testing the idea, I tried 
using %ff-call to call my callback.  I landed in the kernel debugger, 
so I'm doing something very wrong.  Can someone show me how to get this 
bit to work?

$ openmcl
Welcome to OpenMCL Version (Beta: Darwin) 0.14.3-050429!
? (%ff-call (let (fn)
                      (declare (special fn))
                      (defcallback fn (:integer)
                        1)) :integer)
Unhandled exception 4 at 0x0639eeec, context->regs at #xf01356d8
Illegal instruction (0x0639ef06) at 0x0639eeec In foreign code at 
address 0x0639eeec
? for help
[1019] OpenMCL kernel debugger:

I was hoping to get a 1 back.

Now imagine that I declared foo in the let expression (but not as a 
special).  Could the value of foo be used in the callback fn?

eg (if the above worked):

(%ff-call (let (fn (foo 1))
    (declare (special fn))
      (defcallback fn (:integer) foo)) :integer)




More information about the Openmcl-devel mailing list