[cffi-devel] Next release of CFFI with cffi-libffi

Stelian Ionescu sionescu at cddr.org
Thu Apr 19 13:50:38 UTC 2012


On Thu, 2012-04-19 at 14:37 +0100, Luís Oliveira wrote:
> On Thu, Apr 19, 2012 at 11:34 AM, Stelian Ionescu <sionescu at cddr.org> wrote:
> > IMO the change to mem-aref is bad and will break a lot of code. Until
> > now the contract of mem-aref was that it received a pointer to an array
> > of the referenced type and returned a pointer offset into the array.
> > The fact that it now returns a list is a gratuitous change, with no
> > utility. If we actually want these semantics(not sure about it), it
> > should be mem-aptr to implement them
> 
> If it's not too difficult, can you extract a self-contained test case
> that has been broken?

(defcstruct timespec (sec :int64) (usec :int64))

(with-foreign-object (p '(:struct timespec) 2)
  (mem-aref p '(:struct timespec) 1))

In order not to break existing code, I think that mem-aref should
continue to return a pointer in this case instead of a plist. That would
allow cffi-using code to work as it is and not have to be rewritten(an
example that was brought to my attention is
https://gitorious.org/commonqt/commonqt/blobs/master/info.lisp#line312).

Since both functionalities will continue to be present in CFFI, it's
better not to force users to review their code to decide, for each use
of mem-aref, whether it needs to be converted to mem-aptr or not.

-- 
Stelian Ionescu a.k.a. fe[nl]ix
Quidquid latine dictum sit, altum videtur.
http://common-lisp.net/project/iolib

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20120419/b64cfd7b/attachment.sig>


More information about the cffi-devel mailing list