[cffi-devel] Re: Non-top level defcallback
James Bielman
jamesjb at jamesjb.com
Wed May 23 00:41:15 UTC 2007
Stephen Compall wrote:
> On Sun, 2007-05-20 at 19:39 -0700, Tomas Melchior wrote:
>> What platforms/implementations support this? The manual only says "some
>> Lisps". Also, is there anything analogous to lambda for defcallback?
>
> To refer to the text:
>
> *Portability note:* `defcallback' will not work correctly on some Lisps
> if it's not a top-level form.
>
> The point of this note is to say that CFFI doesn't guarantee that it
> will work, much as doing anything not defined by ANSI Common Lisp isn't
> guaranteed to work in portable Common Lisp code. In fact, "some" may
> mean "none at all" now or at any future time. In other words, don't do
> it.
I wonder if we even want to word this more strongly and outright declare
the results undefined or implementation-defined if at non top-level.
DEFCALLBACK is one place that we compromise and pass through to the
Lisp's underlying DEFCALLBACK macro, instead of using a functional
interface. Unfortunately, this can allow implementation details to
leak through, as it does in this case.
I would love to see all supported Lisps providing the underlying
machinery to make a CALLBACK-LAMBDA happen, but I think the number
is currently quite low. :( I did write a patch awhile back adding
this for (IIRC) SBCL and CLISP. It should be in the cffi-devel list
archives.
With a widely supported CALLBACK-LAMBDA, we could implement DEFCALLBACK
in terms of CALLBACK-LAMBDA, as we do with DEFCFUN and FOREIGN-FUNCALL.
I'd like to hope we can get there someday...
James
More information about the cffi-devel
mailing list