On Sat, 10 Apr 2010 17:48:31 +0100, Christophe Rhodes wrote:
> Tamas K Papp <tkpapp@...> writes:
>> On Sat, 10 Apr 2010 16:57:42 +0200, Waldek Hebisch wrote:
>>> I do not want to use C structure, I want to operate on Lisp integers.
>> So you want to use a foreign library, but you don't want to deal with
>> its API? Curious.
> I'm not sure why you think this is curious. It sounds like Waldek is
> saying that the in-memory representation of an sbcl bignum is
> sufficiently close to an in-memory representation of a gmp bignum that
> it's possible to pun them. The disadvantage of doing a principled
> translation between GMP structures and Lisp bignums is...
I think you have misunderstood me (and it may have been my fault). My
impression was that Waldek wanted automagical conversion between SBCL
bignums and GMP. Conversion may be possible (I have seen you code snippet),
but not automatically. Equivalence has to be established.
>>> byproduct use of assembler avoided typechecking problem. But AFAICS
>>> for sbcl it should be possible to avoid copy (at least some copies).
>>> And using assembler with sbcl looks at least as problematic as passing
>>> Lisp data to C.
>> There is no need to use assembler, you just initialize the structure(s)
>> using CFFI or SBCL's FFI. Foreign function interfaces in Common Lisp
>> implementations are no more "problematic" than in any other language.
>> You can even use tools like SWIG to generate the CFFI definitions.
> ... that to convert between the worlds, you'd need to copy, and copying
> takes time. I don't know if it takes too much time, that's application
> dependent, but if there's a way to remove the overhead, then why not?
> Frankly, dismissing this out of hand strikes me as curious.
I don't recall dismissing this. I just claimed that dealing with the
API at some level is necessary. If the representations are (near)
equivalent, so much the better.