| Calling variadic functions from a strongly-typed language |
| Full text |
Pdf
(274 KB)
|
Source
|
International Conference on Functional Programming
archive
Proceedings of the 2008 ACM SIGPLAN workshop on ML
table of contents
Victoria, BC, Canada
SESSION: Session 2
table of contents
Pages 47-58
Year of Publication: 2008
ISBN:978-1-60558-062-3
|
|
Authors
|
|
| Sponsors |
|
| Publisher |
|
| Bibliometrics |
Downloads (6 Weeks): 3, Downloads (12 Months): 30, Citation Count: 0
|
|
|
ABSTRACT
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 easily added to any HOT language implementation that supports calling C functions.
REFERENCES
Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.
| |
1
|
The ATerm Programming Guide. Available from http://homepages.cwi.nl/~daybuild/daily-books/technology/aterm-guide/aterm-guide.html.
|
 |
2
|
|
| |
3
|
Blume, M. No-longer-foreign: Teaching an ML compiler to speak C "natively". In N. Benton and A. Kennedy (eds.), Proceedings of the First International Workshop on Multi-Language Infrastructure and Interoperability (BABEL'01), vol. 59 of Electronic Notes in Theoretical Computer Science, New York, NY, September 2001. Elsevier Science Publishers. Available from http://www.elsevier.nl/locate/entcs/volume59.html.
|
| |
4
|
Chakravarty, M. M. T., S. Finne, F. Henderson, M. Kowalczyk, D. Leijen, S. Marlow, E. Meijer, S. Panne, S. Peyton Jones, A. Reid, M. Wallace, and M. Weber. The Haskell 98 foreign function interface 1.0: An addendum to the Haskell 98 Report. Available from http://www.cse.unsw.edu.au/~chak/haskell/ffi/, 2003.
|
| |
5
|
|
 |
6
|
Sigbjorn Finne , Daan Leijen , Erik Meijer , Simon Peyton Jones, H/Direct: a binary foreign language interface for Haskell, Proceedings of the third ACM SIGPLAN international conference on Functional programming, p.153-162, September 26-29, 1998, Baltimore, Maryland, United States
|
| |
7
|
Fisher, K., R. Pucella, and J. Reppy. Data-level interoperability. Technical report, Bell Labs, Lucent Technologies, April 2000. Available from http://moby.cs.uchicago.edu.
|
| |
8
|
Fisher, K., R. Pucella, and J. Reppy. A framework for interoperability. In N. Benton and A. Kennedy (eds.), Proceedings of the First International Workshop on Multi-Language Infrastructure and Interoperability (BABEL'01), vol. 59 of Electronic Notes in Theoretical Computer Science, New York, NY, September 2001. Elsevier Science Publishers. Available from http://www.elsevier.nl/locate/entcs/volume59.html.
|
| |
9
|
|
 |
10
|
Reuben Olinsky , Christian Lindig , Norman Ramsey, Staged allocation: a compositional technique for specifying and implementing procedure calling conventions, Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, p.409-421, January 11-13, 2006, Charleston, South Carolina, USA
|
|