Skip to main content Accessibility help
×
Home
Hostname: page-component-99c86f546-n7x5d Total loading time: 0.455 Render date: 2021-12-01T16:20:48.809Z Has data issue: true Feature Flags: { "shouldUseShareProductTool": true, "shouldUseHypothesis": true, "isUnsiloEnabled": true, "metricsAbstractViews": false, "figures": true, "newCiteModal": false, "newCitedByModal": true, "newEcommerce": true, "newUsageEvents": true }

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)

Abstract

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

Access options

Get access to the full version of this content by using one of the access options below. (Log in options will check for institutional or personal access. Content may require purchase if you do not have access.)

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).Google 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.Google 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.Google 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.Google 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.
4
Cited by

Send article to Kindle

To send this article to your Kindle, first ensure no-reply@cambridge.org is added to your Approved Personal Document E-mail List under your Personal Document Settings on the Manage Your Content and Devices page of your Amazon account. Then enter the ‘name’ part of your Kindle email address below. Find out more about sending to your Kindle. Find out more about sending to your Kindle.

Note you can select to send to either the @free.kindle.com or @kindle.com variations. ‘@free.kindle.com’ emails are free but can only be sent to your device when it is connected to wi-fi. ‘@kindle.com’ emails can be delivered even when you are not connected to wi-fi, but note that service fees apply.

Find out more about the Kindle Personal Document Service.

Embedding an interpreted language using higher-order functions and types
Available formats
×

Send article to Dropbox

To send this article to your Dropbox account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your <service> account. Find out more about sending content to Dropbox.

Embedding an interpreted language using higher-order functions and types
Available formats
×

Send article to Google Drive

To send this article to your Google Drive account, please select one or more formats and confirm that you agree to abide by our usage policies. If this is the first time you use this feature, you will be asked to authorise Cambridge Core to connect with your <service> account. Find out more about sending content to Google Drive.

Embedding an interpreted language using higher-order functions and types
Available formats
×
×

Reply to: Submit a response

Please enter your response.

Your details

Please enter a valid email address.

Conflicting interests

Do you have any conflicting interests? *