Abstract
We propose a new variant of typed syntactic macro systems named inverse macro, which improves the expressiveness of macro systems. The inverse macro system enables to implement operators with complex side-effects, such as lazy operators and delimited continuation operators, which are beyond the power of existing macro systems. We have implemented the inverse macro system as an extension to Scala 2.11. We also show the expressiveness of the inverse macro system by comparing two versions of shift/reset, bundled in Scala 2.11 and implemented with the inverse macro system.
- K. Asai and O. Kiselyov. Introduction to programming with shift and reset. ACM SIGPLAN Continuation Workshop 2011, 2011.Google Scholar
- J. Bachrach, K. Playford, and C. Street. D-expressions: Lisp power, dylan style. Style DeKalb IL, 1999.Google Scholar
- E. Burmako. Scala macros: Let our powers combine!: On how rich syntax and static types work with metaprogramming. In 4 http://junit.org/, https://projectlombok.org/ 5 http://docs.scala-lang.org/overviews/macros/annotations.html Proceedings of the 4th Workshop on Scala (SCALA ’13), pages 3:1– 3:10, Montpellier, France, July 2013. Google Scholar
Digital Library
- C. Calcagno, W. Taha, L. Huang, and X. Leroy. Implementing multistage languages using asts, gensym, and reflection. In Proceedings of the 2nd International Conference on Generative Programming and Component Engineering (GPCE ’03), pages 57–76, Erfurt, Germany, September 2003. Google Scholar
Digital Library
- W. Clinger and J. Rees. Macros that work. In Proceedings of the 18th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’91), pages 155–162, Orlando, Florida, USA, January 1991. Google Scholar
Digital Library
- O. Danvy and A. Filinski. Abstracting control. In Proceedings of the 1990 ACM conference on LISP and functional programming (LFP ’90), pages 151–160, Nice, France, June 1990. Google Scholar
Digital Library
- D. de Rauglaudre. Camlp4 reference manual, 2003. http: //caml.inria.fr/pub/docs/manual-camlp4/index.html.Google Scholar
- S. Dmitriev. Language oriented programming: The next programming paradigm, 2004.Google Scholar
- https://www.jetbrains.com/mps/docs/ Language_Oriented_Programming.pdf.Google Scholar
- S. Erdweg, T. Rendel, C. Kästner, and K. Ostermann. Sugarj: Librarybased syntactic language extensibility. In Proceedings of the 2011 ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA ’11), pages 391–406, Portland, Oregon, USA, October 2011. Google Scholar
Digital Library
- M. Felleisen. The theory and practice of first-class prompts. In Proceedings of the 15th ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL ’88), pages 180–190, San Diego, CA, USA, January 1988. Google Scholar
Digital Library
- A. Filinski. Representing monads. In Proceedings of the 21st ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’94), pages 446–457, Portland, Oregon, USA, December 1994. Google Scholar
Digital Library
- A. Filinski. Representing layered monads. In Proceedings of the 26th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’99), pages 175–188, San Antonio, Texas, USA, January 1999. Google Scholar
Digital Library
- A. Filinski. Monads in action. In Proceedings of the 37th Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL ’10), pages 483–494, Madrid, Spain, January 2010. Google Scholar
Digital Library
- C. Flanagan, A. Sabry, B. F. Duba, and M. Felleisen. The essence of compiling with continuations. In Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation (PLDI ’93), pages 237–247, Albuquerque, New Mexico, USA, June 1993. Google Scholar
Digital Library
- M. Fowler. Language workbenches: The killer-app for domain specific languages?, 2005. http://martinfowler.com/articles/ languageWorkbench.html.Google Scholar
- C. A. Gunter, D. Rémy, and J. G. Riecke. A generalization of exceptions and control in ML-like languages. In Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture (FPCA ’95), pages 12–23, La Jolla, California, USA, June 1995. Google Scholar
Digital Library
- T. P. Hart. Macro definitions for lisp. 1963.Google Scholar
Digital Library
- K. Ichikawa and S. Chiba. Composable user-defined operators that can express user-defined literals. In Proceedings of the 13th International Conference on Modularity (MODULARITY ’14), pages 13–24, Lugano, Switzerland, April 2014. Google Scholar
Digital Library
- L. C. Kats and E. Visser. The Spoofax language workbench: Rules for declarative specification of languages and ides. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA ’10), pages 444–463, Reno/Tahoe, Nevada, USA, October 2010. Google Scholar
Digital Library
- G. Kiczales, J. Lamping, A. Mendhekar, C. Maeda, C. Lopes, J.-M. Loingtier, and J. Irwin. Aspect-oriented programming. In ECOOP’97 — Object-Oriented Programming, volume 1241 of Lecture Notes in Computer Science, pages 220–242. Springer Berlin Heidelberg, 1997.Google Scholar
- G. Kiczales, E. Hilsdale, J. Hugunin, M. Kersten, J. Palm, and W. G. Griswold. An overview of aspectj. In ECOOP 2001 — Object-Oriented Programming, volume 2072 of Lecture Notes in Computer Science, pages 327–354. Springer Berlin Heidelberg, 2001. Google Scholar
Digital Library
- O. Kiselyov. MetaOCaml — an OCaml dialect for multi-stage programming, 2010. http://okmij.org/ftp/ML/MetaOCaml. html.Google Scholar
- E. Kohlbecker, D. P. Friedman, M. Felleisen, and B. Duba. Hygienic macro expansion. In Proceedings of the 1986 ACM Conference on LISP and Functional Programming (LFP ’86), pages 151–161, Cambridge, Massachusetts, USA, August 1986. Google Scholar
Digital Library
- S. Marlow. The haskell 2010 language report, 2009. http: //www.haskell.org/onlinereport/haskell2010/.Google Scholar
- S. Marlow. Applicative do-notation, 2013. https://ghc.haskell. org/trac/ghc/wiki/ApplicativeDo.Google Scholar
- H. Masuhara and K. Kawauchi. Dataflow pointcut in aspect-oriented programming. In Programming Languages and Systems, volume 2895 of Lecture Notes in Computer Science, pages 105–121. Springer Berlin Heidelberg, 2003.Google Scholar
- C. McBride and R. Paterson. Applicative programming with effects. Journal of Functional Programming, 18(01):1–13, 2008. Google Scholar
Digital Library
- L. R. Nielsen. A selective CPS transformation. In MFPS 2001, Seventeenth Conference on the Mathematical Foundations of Programming Semantics, volume 45 of Electronic Notes in Theoretical Computer Science, pages 311–331. Elsevier, 2001.Google Scholar
- C. Omar, D. Kurilova, L. Nistor, B. Chung, A. Potanin, and J. Aldrich. Safely composable type-specific languages. In ECOOP 2014 — Object-Oriented Programming, volume 8586 of Lecture Notes in Computer Science, pages 105–130. Springer Berlin Heidelberg, 2014.Google Scholar
Digital Library
- C. Queinnec and B. Serpette. A dynamic extent control operator for partial continuations. In Proceedings of the 18th ACM SIGPLANSIGACT Symposium on Principles of Programming Languages (POPL ’91), pages 174–184, Orlando, Florida, USA, January 1991. Google Scholar
Digital Library
- T. Rompf and M. Odersky. Lightweight modular staging: A pragmatic approach to runtime code generation and compiled dsls. In Proceedings of the Ninth International Conference on Generative Programming and Component Engineering (GPCE ’10), pages 127– 136, Eindhoven, The Netherlands, October 2010. Google Scholar
Digital Library
- T. Rompf, I. Maier, and M. Odersky. Implementing first-class polymorphic delimited continuations by a type-directed selective CPS-transform. In Proceedings of the 14th ACM SIGPLAN International Conference on Functional Programming (ICFP ’09), pages 317–328, Edinburgh, Scotland, September 2009. Google Scholar
Digital Library
- T. Rompf, N. Amin, A. Moors, P. Haller, and M. Odersky. Scalavirtualized: linguistic reuse for deep embeddings. Higher-Order and Symbolic Computation, 25(1):1–43, 2013. Google Scholar
Digital Library
- T. Rompf, A. K. Sujeeth, K. J. Brown, H. Lee, H. Chafi, and K. Olukotun. Surgical precision jit compilers. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ’14), pages 41–52, Edinburgh, United Kingdom, July 2014. Google Scholar
Digital Library
- T. Sheard and S. P. Jones. Template meta-programming for Haskell. ACM SIGPLAN Notices, 37(12):60–75, 2002. Google Scholar
Digital Library
- D. Sitaram and M. Felleisen. Control delimiters and their hierarchies. Lisp and Symbolic Computation, 3(1):67–99, 1990. Google Scholar
Digital Library
- K. Skalski, M. Moskal, and P. Olszta. Meta-programming in nemerle. Third International Conference on Generative Programming and Component Engineering (GPCE’04), 2004.Google Scholar
- A. K. Sujeeth, K. J. Brown, H. Lee, T. Rompf, H. Chafi, M. Odersky, and K. Olukotun. Delite: A compiler architecture for performanceoriented embedded domain-specific languages. ACM Transaction on Embedded Computing, 13(4s):134:1–134:25, 2014. Google Scholar
Digital Library
- W. Taha and T. Sheard. Multi-stage programming with explicit annotations. In Proceedings of the 1997 ACM SIGPLAN symposium on Partial evaluation and semantics-based program manipulation (PEPM ’97), pages 203–217, Amsterdam, The Netherlands, June 1997. Google Scholar
Digital Library
Index Terms
Inverse macro in Scala
Recommendations
Inverse macro in Scala
GPCE 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and ExperiencesWe propose a new variant of typed syntactic macro systems named inverse macro, which improves the expressiveness of macro systems. The inverse macro system enables to implement operators with complex side-effects, such as lazy operators and delimited ...
Definitional Interpreters for Higher-Order Programming Languages
Higher-order programming languages (i.e., languages in which procedures or labels can occur as values) are usually defined by interpreters that are themselves written in a programming language based on the lambda calculus (i.e., an applicative language ...
Definitional interpreters for higher-order programming languages
ACM '72: Proceedings of the ACM annual conference - Volume 2Higher-order programming languages (i.e., languages in which procedures or labels can occur as values) are usually defined by interpreters which are themselves written in a programming language based on the lambda calculus (i.e., an applicative language ...






Comments