Hostname: page-component-848d4c4894-2xdlg Total loading time: 0 Render date: 2024-06-14T10:28:15.708Z Has data issue: false hasContentIssue false

Embedding an interpreted language using higher-order functions and types

Published online by Cambridge University Press:  29 September 2011

NORMAN RAMSEY*
Affiliation:
Department of Computer Science, Tufts University, Medford, MA 02155, USA (e-mail: nr@cs.tufts.edu)
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the ‘Save PDF’ action button.

Using an embedded, interpreted language to control a complicated application can have significant software-engineering benefits. But existing interpreters are designed for embedding into C code. To embed an interpreter into a different language requires an API suited to that language. This paper presents Lua-ML, a new API that is suited to languages that provide higher-order functions and types. The API exploits higher-order functions and types to reduce the amount of glue code needed to use an embedded interpreter. Where embedding in C requires a special-purpose “glue function” for every function to be embedded, embedding in Lua-ML requires only a description of each function's type. Lua-ML also makes it easy to define a Lua function whose behavior depends on the number and types of its arguments.

Type
Articles
Copyright
Copyright © Cambridge University Press 2011

References

Beazley, D. M. (1996) SWIG: An easy to use tool for integrating scripting languages with C and C++. In Proceedings of the Fourth Annual Tcl/Tk Workshop, USENIX (ed). Berkeley, CA: USENIX, pp. 129139.Google Scholar
Benson, B. W. (October 1994) Libscheme: Scheme as a C library. In Proceedings of the USENIX Symposium on Very High Level Languages, pp. 7–19.Google Scholar
Benton, N. (July 2005) Embedded interpreters. J. Funct. Program. 15 (4), 503542.CrossRefGoogle Scholar
Blume, M. (September 2001) No-longer-foreign: Teaching an ML compiler to speak C “natively”. In Proceedings of the First Workshop on Multi-Language Infrastructure and Interoperability (BABEL '01).CrossRefGoogle Scholar
Celes, W. (March 2003) toLua–Accessing C/C++ code from Lua [online]. Accessed August 29, 2011. Available at: http://www.tecgraf.puc-rio.br/~celes/toluaGoogle Scholar
Danvy, O. (1996) Type-directed partial evaluation. In Proceedings of the Conference Record of the 23rd Annual ACM Symposium on Principles of Programming Languages, pp. 242–257.CrossRefGoogle Scholar
Danvy, O. (1998) A simple solution to type specialization. In Proceedings of the 25th International Colloquium on Automata, Languages, and Programming (ICALP), Lecture Notes in Computer Science, vol. 1443. Springer-Verlag, pp. 908917.CrossRefGoogle Scholar
Fokker, J. (1995) Functional parsers. In Advanced Functional Programming, Jeuring, J. & Erik, M. (eds), Lecture Notes in Computer Science, vol. 925. Springer Verlag, pp. 123.Google Scholar
Ierusalimschy, R. (December 2003) Programming in Lua. Lua.org. ISBN 85-903798-1-7.Google Scholar
Ierusalimschy, R., de Figueiredo, L. H. & Celes, W. (June 1996a) Lua–An extensible extension language. Softw. Pract. Exp. 26 (6), 635652.3.0.CO;2-P>CrossRefGoogle Scholar
Ierusalimschy, R., de Figueiredo, L. H. & Celes, W. (November 1996b)s Reference Manual of the Programming Language Lua 2.5. TeCGraf, PUC-Rio. Available from the author.Google Scholar
Ierusalimschy, R., de Figueiredo, L. H. & Celes, W. (October 2000) Reference Manual of the Programming Language Lua 4.0. TeCGraf, PUC-Rio. Available at: http://www.lua.orgGoogle Scholar
Ierusalimschy, R., de Figueiredo, L. H. & Celes, W. (May 2001) The evolution of an extension language: A history of Lua. In Proceedings of the V Brazilian Symposium on Programming Languages, pp. B14–B28. Invited paper.Google Scholar
Ierusalimschy, R., de Figueiredo, L. H. & Celes, W. (June 2007) The evolution of Lua. In Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages, pp. 2-1–2-26.CrossRefGoogle Scholar
Jenness, T. & Cozens, S. (July 2002) Extending and Embedding Perl. Manning Publications Company.Google Scholar
Jeske, D. (1998) ***Hz–A real-time action strategy engine [online]. Unpublished software. Accessed August 29, 2011. Available at: http://dj1.willowmail.com/~jeske/Projects/HZ/Google Scholar
Laumann, O. & Bormann, C. (Fall 1994) Elk: The extension language kit. Comput. Syst. 7 (4), 419449.Google Scholar
Leijen, D. & Meijer, E. (January 2000) Domain-specific embedded compilers. Proceedings of the 2nd Conference on Domain-Specific Languages, in SIGPLAN Not. 35 (1), 109122.Google Scholar
Leroy, X., Doligez, D., Garrigue, J., Rémy, D. & Vouillon, J. (July 2004) The Objective Caml system release 3.08: Documentation and user's manual. INRIA. Available at: http://pauillac.inria.fr/ocaml/htmlmanGoogle Scholar
Liang, S., Hudak, P. & Jones, M. (1995) Monad transformers and modular interpreters. In Proceedings of the Conference Record of the 22nd Annual ACM Symposium on Principles of Programming Languages, pp. 333–343.CrossRefGoogle Scholar
Libes, D. (December 1994) Exploring Expect: A Tcl-based Toolkit for Automating Interactive Programs. pub-ORA:adr: O'Reilly & Associates, Inc.Google Scholar
Mogilefsky, B. (May 1999) Lua in Grim Fandango [online]. Accessed July 2011. Available at: http://www.grimfandango.net/?page=articles&pagenumber=2Google Scholar
Olinsky, R., Lindig, C. & Ramsey, N. (January 2006) Staged allocation: A compositional technique for specifying and implementing procedure calling conventions. In Proceedings of the 33rd ACM Symposium on the Principles of Programming Languages, pp. 409–421.CrossRefGoogle Scholar
Ousterhout, J. K. (January 1990) Tcl: An embeddable command language. In Proceedings of the Winter USENIX Conference, pp. 133–146.Google Scholar
Ousterhout, J. K. (1994) Tcl and the Tk Toolkit. Professional Computing Series. Reading, MA: Addison-Wesley.Google Scholar
Peyton Jones, S. L., Ramsey, N. & Reig, F. (September 1999) C--: A portable assembly language that supports garbage collection. In Proceedings of the International Conference on Principles and Practice of Declarative Programming, Lecture Notes in Computer Science, vol. 1702. Springer Verlag, pp. 128.Google Scholar
Ramsey, N. (June 2003) Embedding an interpreted language using higher-order functions and types. In Proceedings of the ACM Workshop on Interpreters, Virtual Machines, and Emulators, pp. 6–14.CrossRefGoogle Scholar
Ramsey, N. (September 2005) ML module mania: A type-safe, separately compiled, extensible interpreter. In Proceedings of the ACM SIGPLAN Workshop on ML, pp. 172–202.Google Scholar
Ramsey, N. & Peyton Jones, S. L.. (May 2000) A single intermediate language that supports multiple implementations of exceptions. Proceedings of the ACM SIGPLAN Conference on Programming Language Design and Implementation, in SIGPLAN Not. 35 (5), 285298.Google Scholar
Rhiger, M. (May 2003) A foundation for embedded languages. ACM Trans. Program. Lang. Syst. 25 (3), 291315.CrossRefGoogle Scholar
Siefkes, C., Assis, F., Chhabra, S. & Yerazunis, W. S. (2004) Combining winnow and orthogonal sparse bigrams for incremental spam filtering. In Proceedings of the 8th European Conference on Principles and Practice of Knowledge Discovery in Databases, Lecture Notes in Computer Science, vol. 3202. Springer, pp. 410421.Google Scholar
van Rossum, G. (2002) Extending and Embedding the Python Interpreter. Release 2.2.2.Google Scholar
Yang, Z. (January 1999) Encoding types in ML-like languages. Proceedings of the 1998 ACM SIGPLAN International Conference on Functional Programming, in SIGPLAN Not. 34 (1), 289300.Google Scholar
Supplementary material: File

Ramsey Supplementary Data

Ramsey Supplementary Data

Download Ramsey Supplementary Data(File)
File 183 KB
Submit a response

Discussions

No Discussions have been published for this article.