ACM Home Page
Please provide us with feedback. Feedback
Macros as multi-stage computations: type-safe, generative, binding macros in MacroML
Full text PdfPdf (233 KB)
Source International Conference on Functional Programming archive
Proceedings of the sixth ACM SIGPLAN international conference on Functional programming table of contents
Florence, Italy
Session: Session 2 table of contents
Pages: 74 - 85  
Year of Publication: 2001
ISBN:1-58113-415-0
Also published in ...
Authors
Steven E. Ganz  Indiana Univ.
Amr Sabry  Indiana Univ.
Walid Taha  Yale Univ.
Sponsor
SIGPLAN: ACM Special Interest Group on Programming Languages
Publisher
ACM  New York, NY, USA
Bibliometrics
Downloads (6 Weeks): 4,   Downloads (12 Months): 35,   Citation Count: 12
Additional Information:

abstract   references   cited by   index terms   collaborative colleagues  

Tools and Actions: Request Permissions Request Permissions    Review this Article  
DOI Bookmark: Use this link to bookmark this Article: http://doi.acm.org/10.1145/507635.507646
What is a DOI?

ABSTRACT

With few exceptions, macros have traditionally been viewed as operations on syntax trees or even on plain strings. This view makes macros seem ad hoc, and is at odds with two desirable features of contemporary typed functional languages: static typing and static scoping. At a deeper level, there is a need for a simple, usable semantics for macros. This paper argues that these problems can be addressed by formally viewing macros as multi-stage computations. This view eliminates the need for freshness conditions and tests on variable names, and provides a compositional interpretation that can serve as a basis for designing a sound type system for languages supporting macros, or even for compilation. To illustrate our approach, we develop and present MacroML, an extension of ML that supports inlining, recursive macros, and the definition of new binding constructs. The latter is subtle, and is the most novel addition in a statically typed setting. The semantics of a core subset of MacroML is given by an interpretation into MetaML, a statically-typed multi-stage programming language. It is then easy to show that MacroML is stage- and type-safe: macro expansion does not depend on runtime evaluation, and both stages do not "go wrong.


REFERENCES

Note: OCR errors may be found in this Reference List extracted from the full text article. ACM has opted to expose the complete List rather than only correct and linked references.

1
 
2
BARENDREGT, H. P. The Lambda Calculus: Its Syntax and Semantics, revised ed, vol. 103 of Studies in Logic and the Foundations of Mathematics. North-Holland, Amsterdam, 1984.
 
3
BENAISSA, Z. E.-A., MOGGI, E., TAHA, W., AND SHEARD, T. Logical modalities and multi-stage programming. In Federated Logic Conference (FLoe,) Satellite Workshop on Intuitionistic Modal Logics and Applications (IMLA) (1999).
 
4
 
5
 
6
CURRY, H. B., AND FEYS, R. Combinatory Logic, Volume I. Studies in Logic and the Foundations of Mathematics. North-Holland, Amsterdam, 1958. Second printing 1968.
 
7
8
 
9
10
 
11
 
12
 
13
 
14
 
15
 
16
G0MARD, C. K., AND JONES, N. D. A partial evaluator for untyped lambda calculus. Journal of Functional Programming 1, 1 (1991), 21-69.
 
17
GRIFFIN, T. G. Notational definitions--a formal account. In Proceedings of the Third Symposium on Logic in Computer Science (1988).
 
18
 
19
 
20
21
22
 
23
 
24
MIILLER, D. An extension to NIL to handle bound variables in data structures: Preliminary report. In Informal Proceedings of the Logical Frameworks BRA Workshop (June 1990). Available as UPenn CIS technical report MS-CIS-90-59.
 
25
 
26
 
27
MOGGI, E. A categorical account of two-level languages. In Mathematics Foundations of Program Semantics (1997). Elsevier Science.
 
28
 
29
 
30
MONNIER, S., AND SHA0, Z. Inlirung as staged computation. Tech. Rep. YALEU/DCS/TR-l 193, Department of Computer Science. Yale University, Mar. 2000.
31
 
32
 
33
 
34
 
35
Oregon Graduate Institute Technical Reports. P.C. Box 91000, Portland. OR 972911000,IJSA. Available online front ftp://cse.ogi.edu/pub/tech-repo~s/README.html. Last viewed August 1999.
 
36
37
 
38
 
39
PLOTKIN, G. D. Call-by-name, call-by-value and the lambda-calculus. Theoretical Computer Science 1 (1975), 125-159.
 
40
 
41
SANDS, D. Computing with contexts: A simple approach. In Second Workshop on HigherOrder Operational Techniques in Semantics (HOOTS II), A. 0. Gordon. A. NI. Pitts, and C. L. Talcott, Eds., vol. 10 of Electron,( Notes in Theoretical Computer Science. Elsevier Science Publishers B.V., 1998.
 
42
SHEARD, T. Using MetahIL: A staged programming language. Lecture Notes in Computer Science 1608 1 207-239.
43
 
44
45
 
46
 
47
TAHA, W., AND MAKHOLM, H. Tag elimination - or type specialisation is a type-indexed effect. In Subtyping and Dependent Types in Programming. APPSEM Workshop. INRIA technical report, 2000.
48
 
49
THIEMANN, P. AND DUSSART, D. Partial evaluation for higher-order languages with state. Available online from http://www.informatik.uni_freiburgdethiemanri/papers index,html. 1996
50
 
51

CITED BY  12

Collaborative Colleagues:
Steven E. Ganz: colleagues
Amr Sabry: colleagues
Walid Taha: colleagues