skip to main content
research-article

Inverse macro in Scala

Published:26 October 2015Publication History
Skip Abstract Section

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.

References

  1. K. Asai and O. Kiselyov. Introduction to programming with shift and reset. ACM SIGPLAN Continuation Workshop 2011, 2011.Google ScholarGoogle Scholar
  2. J. Bachrach, K. Playford, and C. Street. D-expressions: Lisp power, dylan style. Style DeKalb IL, 1999.Google ScholarGoogle Scholar
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. D. de Rauglaudre. Camlp4 reference manual, 2003. http: //caml.inria.fr/pub/docs/manual-camlp4/index.html.Google ScholarGoogle Scholar
  8. S. Dmitriev. Language oriented programming: The next programming paradigm, 2004.Google ScholarGoogle Scholar
  9. https://www.jetbrains.com/mps/docs/ Language_Oriented_Programming.pdf.Google ScholarGoogle Scholar
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. M. Fowler. Language workbenches: The killer-app for domain specific languages?, 2005. http://martinfowler.com/articles/ languageWorkbench.html.Google ScholarGoogle Scholar
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. T. P. Hart. Macro definitions for lisp. 1963.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. O. Kiselyov. MetaOCaml — an OCaml dialect for multi-stage programming, 2010. http://okmij.org/ftp/ML/MetaOCaml. html.Google ScholarGoogle Scholar
  24. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  25. S. Marlow. The haskell 2010 language report, 2009. http: //www.haskell.org/onlinereport/haskell2010/.Google ScholarGoogle Scholar
  26. S. Marlow. Applicative do-notation, 2013. https://ghc.haskell. org/trac/ghc/wiki/ApplicativeDo.Google ScholarGoogle Scholar
  27. 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 ScholarGoogle Scholar
  28. C. McBride and R. Paterson. Applicative programming with effects. Journal of Functional Programming, 18(01):1–13, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. 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 ScholarGoogle Scholar
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  33. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  34. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  35. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  36. T. Sheard and S. P. Jones. Template meta-programming for Haskell. ACM SIGPLAN Notices, 37(12):60–75, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. D. Sitaram and M. Felleisen. Control delimiters and their hierarchies. Lisp and Symbolic Computation, 3(1):67–99, 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. K. Skalski, M. Moskal, and P. Olszta. Meta-programming in nemerle. Third International Conference on Generative Programming and Component Engineering (GPCE’04), 2004.Google ScholarGoogle Scholar
  39. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  40. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Inverse macro in Scala

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 51, Issue 3
      GPCE '15
      March 2016
      184 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2936314
      • Editor:
      • Andy Gill
      Issue’s Table of Contents
      • cover image ACM Conferences
        GPCE 2015: Proceedings of the 2015 ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
        October 2015
        184 pages
        ISBN:9781450336871
        DOI:10.1145/2814204

      Copyright © 2015 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 26 October 2015

      Check for updates

      Qualifiers

      • research-article

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!