Abstract
Existing macro systems force programmers to make a choice between clarity of specification and robustness. If they choose clarity, they must forgo validating significant parts of the specification and thus produce low-quality language extensions. If they choose robustness, they must write in a style that mingles the implementation with the specification and therefore obscures the latter.
This paper introduces a new language for writing macros. With the new macro system, programmers naturally write robust language extensions using easy-to-understand specifications. The system translates these specifications into validators that detect misuses - including violations of context-sensitive constraints - and automatically synthesize appropriate feedback, eliminating the need for ad hoc validation code.
Supplemental Material
- }}Cadence Research Systems. Chez Scheme Reference Manual, 1994.Google Scholar
- }}R. Culpepper and M. Felleisen. Taming macros. In International Conference on Generative Programming and Component Engineering, pages 225--243, 2004.Google Scholar
Cross Ref
- }}T. Despeyroux. Logical programming and error recovery. In Industrial Applications of Prolog, Oct. 1995.Google Scholar
- }}R. K. Dybvig, R. Hieb, and C. Bruggeman. Syntactic abstraction in Scheme. Lisp and Symbolic Computation, 5 (4): 295--326, Dec. 1993. Google Scholar
Digital Library
- }}F. L. Fessant and L. Maranget. Optimizing pattern matching. In International Conference on Functional Programming, pages 26--37, 2001. Google Scholar
Digital Library
- }}R. B. Findler, J. Clements, C. Flanagan, M. Flatt, S. Krishnamurthi, P. Steckler, and M. Felleisen. DrScheme: A programming environment for Scheme. Journal of Functional Programming, 12 (2): 159--182, 2002. Google Scholar
Digital Library
- }}M. Flatt and PLT. Reference: Racket. Technical report, PLT Inc., January 2010. http://racket-lang.org/tr1/.Google Scholar
- }}B. Ford. Packrat parsing: a practical linear-time algorithm with backtracking. Master's thesis, Massachusetts Institute of Technology, Sept. 2002.Google Scholar
- }}D. Herman and M. Wand. A theory of hygienic macros. In European Symposium on Programming, pages 48--62, Mar. 2008. Google Scholar
Digital Library
- }}E. Hilsdale and D. P. Friedman. Writing macros in continuation-passing style. In Workshop on Scheme and Functional Programming, pages 53--59, 2000.Google Scholar
- }}J. Hughes. The design of a pretty-printing library. In Advanced Functional Programming, First International Spring School on Advanced Functional Programming Techniques-Tutorial Text, pages 53--96, London, UK, 1995. Springer-Verlag. Google Scholar
Digital Library
- }}E. E. Kohlbecker and M. Wand. Macro-by-example: Deriving syntactic transformations from their specifications. In Symposium on Principles of Programming Languages, pages 77--84, 1987. Google Scholar
Digital Library
- }}P. J. Landin. Correspondence between ALGOL 60 and Church's lambda-notation: part i. Commun. ACM, 8 (2): 89--101, 1965. Google Scholar
Digital Library
- }}S. Owens, M. Flatt, O. Shivers, and B. McMullan. Lexer and parser generators in Scheme. In Workshop on Scheme and Functional Programming, pages 41--52, Sept. 2004.Google Scholar
- }}O. Shivers. The anatomy of a loop: a story of scope and control. In International Conference on Functional Programming, pages 2--14, 2005. Google Scholar
Digital Library
- }}M. Sperber, R. K. Dybvig, M. Flatt, A. van Straaten, R. Findler, and J. Matthews. Revised6 report of the algorithmic language Scheme. Journal of Functional Programming, 19 (S1): 1--301, Aug. 2009. Google Scholar
Digital Library
- }}M. Wand and D. Vaillancourt. Relating models of backtracking. In International Conference on Functional Programming, pages 54--65, 2004. Google Scholar
Digital Library
Index Terms
Fortifying macros
Recommendations
Macros for domain-specific languages
Macros provide a powerful means of extending languages. They have proven useful in both general-purpose and domain-specific programming contexts. This paper presents an architecture for implementing macro-extensible DSLs on top of macro-extensible host ...
Fortifying macros
ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programmingExisting macro systems force programmers to make a choice between clarity of specification and robustness. If they choose clarity, they must forgo validating significant parts of the specification and thus produce low-quality language extensions. If ...
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