Macros for Domain-Specific Languages

被引:8
作者
Ballantyne, Michael [1 ]
King, Alexis [2 ]
Felleisen, Matthias [1 ]
机构
[1] Northeastern Univ, PLT, Boston, MA 02115 USA
[2] Northeastern Univ, Boston, MA 02115 USA
来源
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL | 2020年 / 4卷 / OOPSLA期
基金
美国国家科学基金会;
关键词
macros; hygiene; extensible domain specific languages;
D O I
10.1145/3428297
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
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 languages. The macro expanders of these DSLs inherit the syntax system, hygienic expansion, and more from the host. They transform the extensible DSL syntax into a DSL core language. This arrangement has several important consequences. It becomes straightforward to integrate the syntax of various DSLs and the host language when their expanders share these inherited components. Also, a DSL compiler may be designed around a fixed core language, even for an extensible DSL. Finally, macros empower programmers to safely grow DSLs on their own and tailor them to their needs.
引用
收藏
页数:29
相关论文
共 53 条
[1]   Super 8 languages for making movies (Functional pearl) [J].
Andersen L. ;
Chang S. ;
Felleisen M. .
Proceedings of the ACM on Programming Languages, 2017, 1 (ICFP)
[2]  
[Anonymous], 2004, TR2004854 NEW YORK U
[3]  
AUGUSTSSON L, 1985, LECT NOTES COMPUT SC, V201, P368
[4]  
Byrd WE, 2017, P ACM PROGRAM LANG, V1, DOI 10.1145/3110252
[5]   Finally tagless, partially evaluated: Tagless staged interpreters for simpler typed languages [J].
Carette, Jacques ;
Kiselyov, Oleg ;
Shan, Chung-Chieh .
JOURNAL OF FUNCTIONAL PROGRAMMING, 2009, 19 :509-543
[6]   Dependent Type Systems as Macros [J].
Chang, Stephen ;
Ballantyne, Michael ;
Turner, Milo ;
Bowman, William J. .
PROCEEDINGS OF THE ACM ON PROGRAMMING LANGUAGES-PACMPL, 2020, 4 (POPL)
[7]  
Chang Stephen, P PRINC PROGR LANG P, DOI [10.1145/3009837.3009886, DOI 10.1145/3009837.3009886]
[8]  
Cheatham Thomas E., 1969, ACM SIGPLAN NOTICES, V4, P45, DOI [10.1145/1115858.1115869, DOI 10.1145/1115858.1115869]
[9]  
Clinger William, 1991, POPL 91, V91, P155, DOI DOI 10.1145/99583.99607
[10]   Fortifying macros [J].
Culpepper, Ryan .
JOURNAL OF FUNCTIONAL PROGRAMMING, 2012, 22 :439-476