Sciweavers

Share
ML
2008
ACM

Calling variadic functions from a strongly-typed language

8 years 10 months ago
Calling variadic functions from a strongly-typed language
The importance of providing a mechanism to call C functions from high-level languages has been understood for many years and, these days, almost all statically-typed high-level-language implementations provide such a mechanism. One glaring omission, however, has been support for calling variadic C functions, such as printf. Variadic functions have been ignored because it is not obvious how to give static types to them and because it is not clear how to generate calling sequence when the arguments to the function may not be known until runtime. In this paper, we address this longstanding omission with an extension to the NLFFI foreign-interface framework used by Standard ML of New Jersey (SML/NJ) and the MLton SML compiler. We describe two different ways of typing variadic functions in NLFFI and an implementation technique based on the idea of using state machines to describe calling conventions. Our implementation is easily retargeted to new architectures and ABIs, and can also be eas...
Matthias Blume, Mike Rainey, John H. Reppy
Added 13 Dec 2010
Updated 13 Dec 2010
Type Journal
Year 2008
Where ML
Authors Matthias Blume, Mike Rainey, John H. Reppy
Comments (0)
books