[MLton-user] Calling C functions with a variable number of
arguments
John Reppy
jhr at cs.uchicago.edu
Mon Jul 26 12:15:51 PDT 2010
We support varargs in SML/NJ using a technique described in a 2008 ML Workshop
paper. A key feature of our approach is that it should be possible to use our
implementation in any ML system that supports C calls. You can find a copy of
the paper at
http://people.cs.uchicago.edu/~jhr/papers/2008/ml-varargs.pdf
On Jul 26, 2010, at 2:00 PM, mlton-user-request at mlton.org wrote:
>
> Hi,
>
> I have been using the FFI and have found it very flexible but have
> run
> into a problem that I can't see how to solve. I am trying to call a
> C
> function with a variable number of arguments but need the variability
> in
> the number of arguments available in SML too.
>
> The attached examples show that there is no problem importing a C
> function with a variable argument list for a fixed number of
> arguments:
> the files 'call_sum_<N>.sml' import the C function 'sum' with N
> arguments for the variable argument list. I need to do something like
>
> val sum = _import "sum" : int * int list -> int;
>
> (I am happy for the variable arguments to have the same type in SML.)
> Does anyone have any ideas about how to achieve a similar effect?
>
> Thanks,
> Phil
More information about the MLton-user
mailing list