skip to main content
10.1145/512529.512562acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
Article

Maya: multiple-dispatch syntax extension in Java

Published:17 May 2002Publication History

ABSTRACT

We have designed and implemented Maya, a version of Java that allows programmers to extend and reinterpret its syntax. Maya generalizes macro systems by treating grammar productions as generic functions, and semantic actions on productions as multimethods on the corresponding generic functions. Programmers can write new generic functions (i.e., grammar productions) and new multimethods (i.e., semantic actions), through which they can extend the grammar of the language and change the semantics of its syntactic constructs, respectively. Maya's multimethods are compile-time metaprograms that transform abstract syntax: they execute at program compile-time, because they are semantic actions executed by the parser. Maya's multimethods can be dispatched on the syntactic structure of the input, as well as the static, source-level types of expressions in the input. In this paper we describe what Maya can do and how it works. We describe how its novel parsing techniques work and how Maya can statically detect certain kinds of errors, such as code that generates references to free variables. Finally, to demonstrate Maya's expressiveness, we describe how Maya can be used to implement the MultiJava language, which was described by Clifton et al. at OOPSLA 2000.

References

  1. A. Aho, R. Sethi, and J. Ullman. Compilers: Principles, Techniques, and Tools. Addison-Wesley, 1986]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. J. Bachrach and K. Playford. The Java syntactic extender (JSE). In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications '01, pages 31--42, Tampa Bay, FL, Oct. 2001]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. Baker. Macros that play: Migrating from Java to Maya. Master's thesis, University of Utah, Dec. 2001. http://www.cs.utah.edu/~jbaker/maya/thesis.html]]Google ScholarGoogle Scholar
  4. J. Baker and W. C. Hsieh. Runtime aspect weaving through metaprogramming. In Proceedings of the First International Conference on Aspect-Oriented Software Development, Enschede, The Netherlands, Apr. 2002]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. D. Batory, B. Lofaso, and Y. Smaragdakis. JTS: Tools for implementing domain-specific languages. In Proc. of the 5th International Conference on Software Reuse, pages 143--153, Victoria, Canada, 1998]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. C. Brabrand and M. Schwartzbach. Growing languages with metamorphic syntax macros. In Proceedings of the Workshop on Partial Evaluation and Semantics-Based Program Manipulation '02, Portland, OR, Jan. 2002. http://www.brics/dk/~mis/macro.ps]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. A. Bryant, A. Catton, K. De~Volder, and G. C. Murphy. Explicit programming. In Proceedings of the First International Conference on Aspect-Oriented Software Development, Enschede, The Netherlands, Apr. 2002]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. L. Cardelli, F. Matthes, and M. Abadi. Extensible syntax with lexical scoping. Technical Report 121, DEC SRC, Feb. 1994]]Google ScholarGoogle Scholar
  9. C. Chambers. The Cecil Language Specification and Rationale: Version 2.0, 1995]]Google ScholarGoogle Scholar
  10. S. Chiba. A metaobject protocol for C++. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications'95, pages 285--299, Austin, TX, 1995]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. C. Clifton. The MultiJava project. http://www.cs.iastate.edu/~cclifton/multijava/index.shtml]]Google ScholarGoogle Scholar
  12. C. Clifton, G. Leavens, C. Chambers, and T. Millstein. MultiJava: Modular open classes and symmetric multiple dispatch for Java. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications '00, pages 130--146, Minneapolis, MN, Oct. 2000]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. W. Clinger and J. Reese. Macros that work. In Proceedings of the 18th Annual ACM Symposium on Principles of Programming Languages, pages 155--162, Toronto, Ontario, Jan. 1991]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. D. de Rauglaudre. Camlp4 reference manual. http://caml.inria.fr/camlp4/manual/, Jan. 2002]]Google ScholarGoogle Scholar
  15. W. Divoky, C. Forgione, T. Graf, C. Laborde, A. Lemonnier, and E. Wais. The Kopi project. http://www.dms.at/kopi/index.html]]Google ScholarGoogle Scholar
  16. R. Ducournau, M. Habib, M. Huchard, and M. Mugnier. Monotonic conflict resolution mechanisms for inheritance. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications '92, pages 16--24, Vancouver, BC, Oct. 1992]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. R. K. Dybvig, R. Hieb, and C. Bruggeman. Syntactic abstraction in Scheme. Lisp and Symbolic Computation, 5(4):pp. 295--326, 1993]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. M. Ernst, C. Kaplan, and C. Chambers. Predicate dispatching: A unified theory of dispatch. In Proceedings of the Conference on Object-Oriented Programming Systems, Languages, and Applications '98, pages 186--211, Vancouver, BC, Oct. 1998]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Massachusetts, 1994]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. S. Ganz, A. Sabry, and W. Taha. Macros as multi-stage computations: Type-safe, generative, binding macros in MacroML. In Proceedings of the International Conference on Functional Programming '01, pages 74--85, Florence, Italy, Sept. 2001]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. R. Kelsey, W. Clinger, and J. Rees (Eds.). The revised report on the algorithmic language Scheme. ACM SIGPLAN Notices, 33(9), Sept. 1998]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. S. Krishnamurthi. Linguistic Reuse. PhD thesis, Rice University, 2001]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. D. A. Ladd and J. C. Ramming. A*: A language for implementing language processors. IEEE Transactions on Software Engineering, 21(11):894--901, Nov. 1995]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. W. Maddox. Semantically-sensitive macroprocessing. Master's thesis, University of California, Berkeley, 1989]]Google ScholarGoogle Scholar
  25. Microsoft. C# language specification. http://msdn.microsoft.com/library/dotnet/csspec/vclrfcsharpspec_Start.htm]]Google ScholarGoogle Scholar
  26. M. Poletto, W. Hsieh, D. Engler, and M. Kaashoek. "`C and tcc: A Language and Compiler for Dynamic Code Generation". ACM Transactions on Programming Languages and Systems, 21(2):324--369, 1999]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. A. Shalit. Dylan Reference Manual. Addison-Wesley, 1996]]Google ScholarGoogle Scholar
  28. G. Steele Jr. Common Lisp, the Language. Digital Press, second edition, 1990]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. M. Tatsubori, S. Chiba, M. Killijian, and K. Itano. OpenJava: A class-based macro system for Java. In Proceedings of the OOPSLA '00 Reflection and Software Engineering Workshop, Minneapolis, MN, Oct. 2000]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. D. Weise and R. Crew. Programmable syntax macros. In Proceedings of the SIGPLAN '93 Conference on Programming Language Design and Implementation, pages 156--165, Albuquerque, NM, June 1993]] Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Xerox. The AspectJ programming guide. http://www.aspectj.org/doc/dist/progguide/]]Google ScholarGoogle Scholar

Index Terms

  1. Maya: multiple-dispatch syntax extension in Java

    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
    • Published in

      cover image ACM Conferences
      PLDI '02: Proceedings of the ACM SIGPLAN 2002 conference on Programming language design and implementation
      June 2002
      338 pages
      ISBN:1581134630
      DOI:10.1145/512529

      Copyright © 2002 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 17 May 2002

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      PLDI '02 Paper Acceptance Rate28of169submissions,17%Overall Acceptance Rate406of2,067submissions,20%

      Upcoming Conference

      PLDI '24

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader