[cffi-devel] Can closures be used as callbacks in CFFI?
Dear developers, can closures be used as callbacks, i.e. will the following kind of code work? (let ((ptr nil)) (let ((a 3)) (defcallback add-a :int ((b :int)) (+ a b)) (setq ptr (callback add-a))) (c-function ptr)) Best regards Bruno Daniel
Dear developers, I apologize for asking this question, since I just found out that it has already been addressed last year: http://common-lisp.net/pipermail/cffi-devel/2006-February/000525.html "Re: unnamed callback (closures?) [...] If all else failed, you could resort to passing something like: #+sbcl (alien-sap (alien-lambda ...)) #+ecl #| whatever is appropriate for an ecl anon callback |# as a pointer to a CFFI function." I'm a little bit worried because alien-lambda is undocumented in both the SBCL and the CMUCL manuals. Best regards, Bruno Daniel
participants (1)
-
Bruno Daniel