Abstract
Programming language design benefits from constructs for extending the syntax and semantics of a host language. While C's string-based macros empower programmers to introduce notational shorthands, the parser-level macros of Lisp encourage experimentation with domain-specific languages. The Scheme programming language improves on Lisp with macros that respect lexical scope.
The design of Racket---a descendant of Scheme---goes even further with the introduction of a full-fledged interface to the static semantics of the language. A Racket extension programmer can thus add constructs that are indistinguishable from "native" notation, large and complex embedded domain-specific languages, and even optimizing transformations for the compiler backend. This power to experiment with language design has been used to create a series of sub-languages for programming with first-class classes and modules, numerous languages for implementing the Racket system, and the creation of a complete and fully integrated typed sister language to Racket's untyped base language.
This paper explains Racket's language extension API via an implementation of a small typed sister language. The new language provides a rich type system that accommodates the idioms of untyped Racket. Furthermore, modules in this typed language can safely exchange values with untyped modules. Last but not least, the implementation includes a type-based optimizer that achieves promising speedups. Although these extensions are complex, their Racket implementation is just a library, like any other library, requiring no changes to the Racket implementation.
- Jonathan Bachrach and Keith Playford. The Java syntactic extender. In Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 31--42, 2001. Google Scholar
Digital Library
- Eli Barzilay and John Clements. Laziness Without All the Hard Work. In Proc. Works. Functional and Declarative Programming in Education, pp. 9--13, 2005. Google Scholar
Digital Library
- Martin Bravenboer and Eelco Visser. Concrete syntax for objects: domainspecific language embedding and assimilation without restrictions. In Proc. Conf. Object-Oriented Programming Systems, Languages, and Applications, pp. 365--383, 2004. Google Scholar
Digital Library
- John Clements, Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram Krishnamurthi. Fostering Little Languages. Dr. Dobb's Journal, pp. 16--24, 2004.Google Scholar
- William D. Clinger and Lars Thomas Hansen. Lambda, the ultimate label or a simple optimizing compiler for Scheme. In Proc. Conf. on LISP and functional programming, pp. 128--139, 1994. Google Scholar
Digital Library
- Russ Cox, Tom Bergan, Austin T. Clements, Frans Kaashoek, and Eddie Kohler. Xoc, an extension-oriented compiler for systems programming. In Proc. Conf. Architectural Support for Programming Languages and Operating Systems, pp. 244--254, 2008. Google Scholar
Digital Library
- Ryan Culpepper and Matthias Felleisen. Debugging hygienic macros. Science of Computer Programming 75(7), pp. 496--15, 2010. Google Scholar
Digital Library
- Ryan Culpepper and Matthias Felleisen. Fortifying macros. In Proc. International Conf. on Functional Programming, pp. 235--246, 2010. Google Scholar
Digital Library
- Ryan Culpepper, Scott Owens, and Matthew Flatt. Syntactic abstraction in component interfaces. In Proc. Conf. Generative Programming and Component Engineering, pp. 373--388, 2005. Google Scholar
Digital Library
- Ryan Culpepper, Sam Tobin-Hochstadt, and Matthias Felleisen. Advanced Macrology and the Implementation of Typed Scheme. In Proc. Scheme and Functional Programming, 2007.Google Scholar
- R. Kent Dybvig. Chez Scheme Version 8 User's Guide. Cadence Research Systems, 2009.Google Scholar
- R. Kent Dybvig, Robert Hieb, and Carl Bruggeman. Syntactic abstraction in Scheme. Lisp and Symbolic Computation 5(4), pp. 295--326, 1992. Google Scholar
Digital Library
- Marc Feeley and James S. Miller. A parallel virtual machine for efficient Scheme compilation. In Proc. Conf. on LISP and Functional Programming, pp. 119--130, 1990. Google Scholar
Digital Library
- Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, and Shriram Krishnamurthi. Building Little Languages With Macros. Dr. Dobb's Journal, pp. 45--49, 2004.Google Scholar
- David Fisher and Olin Shivers. Static semantics for syntax objects. In Proc. International Conf. on Functional Programming, pp. 111--121, 2006. Google Scholar
Digital Library
- David Fisher and Olin Shivers. Building language towers with Ziggurat. J. of Functional Programming 18(5-6), pp. 707--780, 2008. Google Scholar
Digital Library
- Matthew Flatt. Composable and compilable macros: you want it when? In Proc. International Conf. on Functional Programming, pp. 72--83, 2002. Google Scholar
Digital Library
- Matthew Flatt, Eli Barzilay, and Robert Bruce Findler. Scribble: closing the book on ad-hoc documentation tools. In Proc. International Conf. on Functional Programming, pp. 109--120, 2009. Google Scholar
Digital Library
- Matthew Flatt and Matthias Felleisen. Units: Cool modules for HOT languages. In Proc. Conf. on Programming Language Design and Implementation, pp. 236--248, 1998. Google Scholar
Digital Library
- Matthew Flatt, Robert Bruce Findler, and Matthias Felleisen. Scheme with classes, mixins, and traits. In Proc. Asian Symp. on Programming Languages and Systems, pp. 270--289, 2006. Google Scholar
Digital Library
- Matthew Flatt and PLT. Reference: Racket. PLT Inc., PLT-TR-2010-1, 2010. http://racket-lang.org/tr1/.Google Scholar
- Richard P. Gabriel. Performance and Evaluation of LISP Systems. MIT Press, 1985. Google Scholar
Digital Library
- Anwar Ghuloum, Amanda Sharp, Noah Clemons, Stefanus Du Toit, Rama Malladi, Mukesh Gangadhar, Michael McCool, and Hans Pabst. Array Building Blocks: A Flexible Parallel Programming Model for Multicore and Many-Core Architectures. Dr. Dobb's Journal, 2010.Google Scholar
- Pieter H. Hartel, Marc Feeley, Martin Alt, Lennart Augustsson, Peter Baumann, Marcel Beemster, Emmanuel Chailloux, Christine H. Flood, Wolfgang Grieskamp, John H. G. van Groningen, Kevin Hammond, BogumiB Hausman, Melody Y. Ivory, Richard E. Jones, Jasper Kamperman, Peter Lee, Xavier Leroy, Rafael D. Lins, Sandra Loosemore, Niklas Röjemo, Manuel Serrano, Jean-Pierre Talpin, Jon Thackray, Stephen Thomas, Pum Walters, Pierre Weis, and E.P. Wentworth. Benchmarking implementations of functional languages with 'pseudoknot' a float-intensive benchmark. J. of Functional Programming 6(4), pp. 621--655, 1996.Google Scholar
Cross Ref
- Manuel V. Hermenegildo, Francisco Bueno, Manuel Carro, Pedro Lopez, José F. Morales, and German Puebla. An overview of the Ciao multiparadigm language and program development environment and its design philosophy. In Concurrency, Graphs and Models. Springer-Verlag, pp. 209--237, 2008. Google Scholar
- Richard Andrew Kelsey. Compilation by Program Transformation. PhD dissertation, Yale University, 1989.Google Scholar
- Shriram Krishnamurthi. Linguistic Reuse. PhD dissertation, Rice University, 2001. Google Scholar
Digital Library
- Shriram Krishnamurthi, Peter Walton Hopkins, Jay McCarthy, Paul T. Graunke, Greg Pettyjohn, and Matthias Felleisen. Implementation and use of the PLT Scheme web server. Higher-Order and Symbolic Computing 20(4), pp. 431--460, 2007. Google Scholar
Digital Library
- Simon Marlow. Haskell 2010 Language Report. 2010.Google Scholar
- Robin Milner, Mads Tofte, Robert Harper, and David MacQueen. The Definition of Standard ML, Revised Edition. MIT Press, 1997. Google Scholar
Digital Library
- Nathaniel Nystrom, Michael Clarkson, and Andrew Myers. Polyglot: an extensible compiler framework for Java. In Proc. International Conf. on Compiler Construction, pp. 138--152, 2003. Google Scholar
Digital Library
- Simon L Peyton Jones. Compiling Haskell by program transformation a report from the trenches. In Proc. European Symp. on Programming, pp. 18--44, 1996. Google Scholar
Digital Library
- Hari Prashanth K R and Sam Tobin-Hochstadt. Functional data structures for Typed Racket. In Proc. Works. Scheme and Functional Programming, pp. 1--7, 2010.Google Scholar
- Manuel Serrano and Pierre Weis. Bigloo: a portable and optimizing compiler for strict functional languages. In Proc. Static Analysis Symp., pp. 366--381, 1995. Google Scholar
Digital Library
- Michael Sperber, Matthew Flatt, Anton Van Straaten, R. Kent Dybvig, Robert Bruce Findler, and Jacob Matthews. Revised6 report on the algorithmic language Scheme. J. of Functional Programming 19(S1), pp. 1--301, 2009. Google Scholar
Digital Library
- Guy L. Steele Jr. Common Lisp: The Language. Second edition. Digital Press, 1994. Google Scholar
Digital Library
- Guy L. Steele Jr. Growing a language, Keynote at OOPSLA 1998. Higher-Order and Symbolic Computation 12(3), pp. 221--236, 1999. Google Scholar
Digital Library
- Guy L. Steele Jr. and Richard P. Gabriel. The evolution of Lisp. In Proc. Conf. on History of Programming Languages, pp. 231--270, 1993. Google Scholar
Digital Library
- T. Stephen Strickland, Sam Tobin-Hochstadt, and Matthias Felleisen. Practical Variable-Arity Polymorphism. In Proc. European Symp. on Programming, 2009. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. Interlanguage refactoring: from scripts to programs. In Proc. Dynamic Languages Symp., pp. 964--974, 2006. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. The design and implementation of Typed Scheme. In Proc. Symp. on Principles of Programming Languages, pp. 395--406, 2008. Google Scholar
Digital Library
- Sam Tobin-Hochstadt and Matthias Felleisen. Logical types for untyped languages. In Proc. International Conf. on Functional Programming, pp. 117--128, 2010. Google Scholar
Digital Library
- Eugene Kohlbecker. Syntactic Extensions in the Programming Language Lisp. PhD dissertation, Indiana University, 1986. Google Scholar
Digital Library
Index Terms
Languages as libraries
Recommendations
Languages as libraries
PLDI '11: Proceedings of the 32nd ACM SIGPLAN Conference on Programming Language Design and ImplementationProgramming language design benefits from constructs for extending the syntax and semantics of a host language. While C's string-based macros empower programmers to introduce notational shorthands, the parser-level macros of Lisp encourage ...
Composable and compilable macros:: you want it when?
ICFP '02: Proceedings of the seventh ACM SIGPLAN international conference on Functional programmingMany macro systems, especially for Lisp and Scheme, allow macro transformers to perform general computation. Moreover, the language for implementing compile-time macro transformers is usually the same as the language for implementing run-time functions. ...
Composable and compilable macros:: you want it when?
Many macro systems, especially for Lisp and Scheme, allow macro transformers to perform general computation. Moreover, the language for implementing compile-time macro transformers is usually the same as the language for implementing run-time functions. ...







Comments