On Thu, 2006-10-12 at 23:20 +0100, Luís Oliveira wrote:
> On 10/12/06, Juan Jose Garcia-Ripoll <[EMAIL PROTECTED]> wrote:
> > Supplying the argument types is extremely tricky in some cases and
> > might not be enough type information. For example,
> >       int f1(int i, ...)
> > is not the same function as
> >       int f2(int i, int j)
> > even though when we invoke f1(1, 2) the (2) is coerced to type int.
> 
> On all platforms I have access too they seem to behave the same since
> we manage to call varargs functions and the various Lisps don't know
> anything about their varargs-ness. I hear that might not always be
> true, so see below.

I think a key difference is that in ECL's case, we are compiling via
the C compiler which does actually know whether a function is varargs
or not.  The Lisp implementations that compile to native code have to
set up the call arguments such that they work with both varargs and
non-varargs functions.

What if, instead of using FOREIGN-FUNCALL-VARARGS, we added an extra
keyword argument that could be placed in the FOREIGN-FUNCALL arguments
as a marker for the boundary between the required and variadic
arguments?  Something like:

  (foreign-funcall "printf" :string "%d" :varargs :int 42)

It's not exactly pretty (and we still can't force people to use it on
the Lisps that don't require it), but there is less loss of information
for the C compiler...

James


_______________________________________________
cffi-devel mailing list
cffi-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel

Reply via email to