Hostname: page-component-586b7cd67f-l7hp2 Total loading time: 0 Render date: 2024-11-25T04:59:15.688Z Has data issue: false hasContentIssue false

Macros that Work Together

Compile-time bindings, partial expansion, and definition contexts

Published online by Cambridge University Press:  09 May 2012

MATTHEW FLATT
Affiliation:
RYAN CULPEPPER
Affiliation:
DAVID DARAIS
Affiliation:
ROBERT BRUCE FINDLER
Affiliation:
Northwestern University (e-mail: [email protected])
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.

Racket is a large language that is built mostly within itself. Unlike the usual approach taken by non-Lisp languages, the self-hosting of Racket is not a matter of bootstrapping one implementation through a previous implementation, but instead a matter of building a tower of languages and libraries via macros. The upper layers of the tower include a class system, a component system, pedagogic variants of Scheme, a statically typed dialect of Scheme, and more. The demands of this language-construction effort require a macro system that is substantially more expressive than previous macro systems. In particular, while conventional Scheme macro systems handle stand-alone syntactic forms adequately, they provide weak support for macros that share information or macros that use existing syntactic forms in new contexts. This paper describes and models features of the Racket macro system, including support for general compile-time bindings, sub-form expansion and analysis, and environment management. The presentation assumes a basic familiarity with Lisp-style macros, and it takes for granted the need for macros that respect lexical scope. The model, however, strips away the pattern and template system that is normally associated with Scheme macros, isolating a core that is simpler, can support pattern and template forms themselves as macros, and generalizes naturally to Racket's other extensions.

Type
Articles
Copyright
Copyright © Cambridge University Press 2012

References

Bawden, A. & Rees, J (1988) Syntactic closures. In Proceedings of the Lisp and Functional Programming, July 25–27, Snowbird, UT, USA. Pittsburgh: ACM, pp. 8695.Google Scholar
Clinger, William D. (1991) Hygienic macros through explicit renaming. LISP Pointers 4 (4), 2528.CrossRefGoogle Scholar
Clinger, C. & Rees, J. (1991) Macros that work. In Proceedings of ACM Symposium on Principles of Programming Languages. New York, NY: ACM, pp. 155162.Google Scholar
Dybvig, R. Kent, Friedman, Daniel P. & Haynes, Christopher T. (1988) Expansion-passing style: A general macro mechanism. LISP Symb. Comput. 1 (1), 5375.Google Scholar
Dybvig, R. Kent, Hieb, R. & Bruggeman, C. (1993) Syntactic abstraction in Scheme. LISP Symb. Comput. 5 (4), 295326.Google Scholar
Felleisen, M., Findler, R. B. & Flatt, M. (2009) Semantics Engineering with PLT Redex. Cambridge, MA: MIT Press.Google Scholar
Fisher, D. & Shivers, O (2008) Building language towers with Ziggurat. J. Funct. Program. 18 (5–6), 707780.CrossRefGoogle Scholar
Flatt, M. (2002) Compilable and composable macros, you want it when? In Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming (ICFP 2002), Pittsburgh, PA, USA, October 4–6, pp. 7283.CrossRefGoogle Scholar
Gabbay, M. & Pitts, A. (1999) A new approach to abstract syntax involving binders. In the Proceedings of the 14th IEEE Symposium on Logic in Computer Science (LICS'99), Trento, Italy, pp. 341363.Google Scholar
Gasbichler, M. (2006) Fully-Parameterized Higher-Order Modules with Hygienic Macros. PhD dissertation, Universität Tübingen, Tübingen, Germany.Google Scholar
Ghuloum, A. & Dybvig, R. Kent (2007) Portable syntax-case. Accessed April, 2012. Available at: https://www.cs.indiana.edu/chezscheme/syntax-case/Google Scholar
Herman, D. (2010) A Theory of Typed Hygienic Macros. PhD dissertation, Northeastern University, Boston, Massachusetts.Google Scholar
Hilsdale, E. & Friedman, D. P. (2000) Writing macros in continuation-passing style. Proceedings of the Workshop on Scheme and Functional Programming, Montreal, September 17.Google Scholar
Kohlbecker, E. Eugene, Friedman, Daniel P, Felleisen, M. & Duba, B. (1986) Hygienic macro expansion. In Proceedings of the ACM Conference on Lisp and Functional Programming. New York, NY: ACM, pp. 151181.Google Scholar
Kohlbecker, E. Eugene & Wand, M. (1987) Macro-by-example: Deriving syntactic transformations from their specifications. In Proceedings of the 14th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, Munich, Germany, January 2123, pp. 7784.CrossRefGoogle Scholar
Milner, R., Tofte, M. & Harper, R. (1990) The Definition of Standard ML. Cambridge, MA: MIT Press.Google Scholar
Pfenning, F. & Elliott, C. (1988) Higher-order abstract syntax. In Proceedings of the SIGPLAN '88 Conference on Programming Language Design and Implementation. New York, NY: ACM, pp. 199208.Google Scholar
Pfenning, F. & Schürmann, C. (1999) System description: Twelf – a meta-logical framework for deductive systems. In Proceedings of the International Conference on Automated Deduction, Trento, Italy, pp. 202206.Google Scholar
Sheard, T. & Peyton Jones, S. (2002) Template meta-programming for Haskell. In Proceedings of Haskell Workshop 2002, Pittsburgh, PA, USA, pp. 6075.Google Scholar
Shinwell, Mark R., Pitts, A. M. & Gabbay, M. J. (2003) FreshML: Programming with binders made simple. In Proceedings of the 8th ACM International Conference on Functional Programming. New York, NY: ACM, pp. 263274.Google Scholar
Sperber, M. (Ed.) (2009) Revised 6 report on the algorithmic language Scheme. J. Funct. Program. 19(supplement), 1301.CrossRefGoogle Scholar
Van Tonder, A. (2007) R6RS libraries and macros. Accessed April, 2012. Available at: http://www.het.brown.edu/people/andre/macros/Google Scholar
Van Wyk, E., Bodin, D., Krishnan, L. & Gao, J. (2009) Silver: an extensible attribute grammar system. Sci. Comput. Program. 75 (1–2) doi: 10.1016/j.scico.2009.07.004Google Scholar
Waddell, O. & Dybvig, R. Kent (1999) Extending the scope of syntactic abstraction. In Proceedings of ACM Symposium on the Principles of Programming Languages. New York, NY: ACM, pp. 203213.Google Scholar
Submit a response

Discussions

No Discussions have been published for this article.