[Openmcl-devel] should ccl allow ffi callbacks to be defined within closures

Madhu enometh at meer.net
Tue May 21 23:48:40 PDT 2024


I came across a use of cffi callbacks which defines the callback
within a function. In CCL the following

```
(defun barf ()
  (ccl:defcallback CMPSTRINGP (:address p1 :address p2 :signed-int)
      (ccl:external-call "strcmp" :address p1 :address p2 :signed-int)))
(barf)

=>
Condition of type TYPE-ERROR:

The value (:INTERNAL CMPSTRINGP BARF) is not of the expected type
 (AND SYMBOL (NOT (SATISFIES CONSTANTP)))
```

Is there any reason to disallow callbacks defined by defcallbacks from
being closures which capture their environment?

I am attaching a patch which continues to use the name specified by
DEFCALLBACK even if the defining function is a closure.

I'd very much appreciate it if other developers could review it and
give feedback.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-allow-ffi-callbacks-to-be-defined-within-closures.patch
Type: text/x-patch
Size: 1663 bytes
Desc: not available
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20240522/050797aa/attachment.bin>


More information about the Openmcl-devel mailing list