<br><br><div class="gmail_quote">2010/9/12 Gustavo <span dir="ltr"><<a href="mailto:gugamilare@gmail.com">gugamilare@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Well, in this case you can use copy CFFI's code for that macro and that function to make your library work with more implementations. </blockquote><div><br>Maybe I'm confused about what you mean, but WAAF already works with all implementations<br>
that work with CFFI. It's just that it uses foreign alloc and copying rather than tricks to make<br>pointers to native Lisp arrays. <br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Or, wouldn't it be much better if you patch CFFI so that CFFI:MAKE-SHAREABLE-BYTE-VECTOR would be able to create arrays of different element types?</blockquote><div><br><br>I guess one could do this, but wouldn't this mean that only shareable arrays could be passed to foreign<br>
code? Not any lisp array? In return, for some implementations, you would avoid copying<br>to and from malloc'ed memory. <br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
You could create functions that transform between Lisp and C types (such as :int <-> '(signed-byte 32)).</blockquote><div><br>Yes, this is what my code does. It constructs a library (a hash table, internally) of optimized lisp <br>
functions to do the copying, one for each LISP<-->CFFI type pair, plus a generic set at a higher safety <br>level where the Lisp type is just T. But doesn't inline or macroexpand the copying because I don't <br>
think this buys much because most of the cycles are likely spent iterating, not funcallling.<br><br>There are a various approaches to take when passing arrays. What is important from my own <br>perspective, as a user, is to have them publicized and accessible, so I don't end up reinventing them. <br>
Hence I put my solution on cliki's FFI page. Very likely, at some point cffi will have functionality<br>that renders it redundant.<br><br> </div></div><br>