On Thu, Apr 19, 2012 at 9:50 AM, Stelian Ionescu sionescu@cddr.org wrote:
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@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
As Luis pointed out, no code should be broken because '(:struct foo) wasn't used before. The example you point to has a symbol representing the type '|struct MethodMap| which I guess is being interpreted as if it were'(:struct MethodMap). I'm not sure, but that's the only way I can see this not being interpreted as a bare structure. If it were interpreted as a bare structure, everything should work as before.
Liam