TY - GEN
T1 - Macros that compose
T2 - 1st ACM SIGPLAN/SIGSOFT International Conference on Generative Programming and Component Engineering, GPCE 2002
AU - Kiselyov, Oleg
N1 - Publisher Copyright:
© Springer-Verlag Berlin Heidelberg 2002.
PY - 2002
Y1 - 2002
N2 - Macros are often regarded as a sort of black magic: highly useful yet abstruse. The present paper aims to make macro programming more like a craft. Using R5RS Scheme macros as an example, we develop and present a general practical methodology of building complex macros systematically, by combining simpler components by functional composition or higher-order operators. Macro programming is complex because the systematic approach does not apply to many macros. We show that macros and other head-first normal-order re-writing systems generally lack functional composition. However, macros written in a continuation-passing style (CPS) always compose. Making CPS macros practical still requires an encoding for macro-continuations. We have found this missing piece, with an insight for anonymous macro-level abstractions. In the specific case of R5RS macros, this paper presents a stronger result: developing R5RS macros by a translation from the corresponding Scheme procedures. We demonstrate the practical use of the technique by elaborating a real-world example.
AB - Macros are often regarded as a sort of black magic: highly useful yet abstruse. The present paper aims to make macro programming more like a craft. Using R5RS Scheme macros as an example, we develop and present a general practical methodology of building complex macros systematically, by combining simpler components by functional composition or higher-order operators. Macro programming is complex because the systematic approach does not apply to many macros. We show that macros and other head-first normal-order re-writing systems generally lack functional composition. However, macros written in a continuation-passing style (CPS) always compose. Making CPS macros practical still requires an encoding for macro-continuations. We have found this missing piece, with an insight for anonymous macro-level abstractions. In the specific case of R5RS macros, this paper presents a stronger result: developing R5RS macros by a translation from the corresponding Scheme procedures. We demonstrate the practical use of the technique by elaborating a real-world example.
UR - http://www.scopus.com/inward/record.url?scp=84937416306&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=84937416306&partnerID=8YFLogxK
U2 - 10.1007/3-540-45821-2_13
DO - 10.1007/3-540-45821-2_13
M3 - Conference contribution
AN - SCOPUS:84937416306
T3 - Lecture Notes in Computer Science (including subseries Lecture Notes in Artificial Intelligence and Lecture Notes in Bioinformatics)
SP - 202
EP - 217
BT - Generative Programming and Component Engineering - ACM SIGPLAN/SIGSOFT Conference, GPCE 2002, Proceedings
A2 - Batory, Don
A2 - Consel, Charles
A2 - Taha, Walid
PB - Springer Verlag
Y2 - 6 October 2002 through 8 October 2002
ER -