Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
article

Maya: multiple-dispatch syntax extension in Java

Published: 17 May 2002 Publication 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]]
[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]]
[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]]
[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]]
[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]]
[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]]
[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]]
[8]
L. Cardelli, F. Matthes, and M. Abadi. Extensible syntax with lexical scoping. Technical Report 121, DEC SRC, Feb. 1994]]
[9]
C. Chambers. The Cecil Language Specification and Rationale: Version 2.0, 1995]]
[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]]
[11]
C. Clifton. The MultiJava project. http://www.cs.iastate.edu/~cclifton/multijava/index.shtml]]
[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]]
[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]]
[14]
D. de Rauglaudre. Camlp4 reference manual. http://caml.inria.fr/camlp4/manual/, Jan. 2002]]
[15]
W. Divoky, C. Forgione, T. Graf, C. Laborde, A. Lemonnier, and E. Wais. The Kopi project. http://www.dms.at/kopi/index.html]]
[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]]
[17]
R. K. Dybvig, R. Hieb, and C. Bruggeman. Syntactic abstraction in Scheme. Lisp and Symbolic Computation, 5(4):pp. 295--326, 1993]]
[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]]
[19]
E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Massachusetts, 1994]]
[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]]
[21]
R. Kelsey, W. Clinger, and J. Rees (Eds.). The revised report on the algorithmic language Scheme. ACM SIGPLAN Notices, 33(9), Sept. 1998]]
[22]
S. Krishnamurthi. Linguistic Reuse. PhD thesis, Rice University, 2001]]
[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]]
[24]
W. Maddox. Semantically-sensitive macroprocessing. Master's thesis, University of California, Berkeley, 1989]]
[25]
Microsoft. C# language specification. http://msdn.microsoft.com/library/dotnet/csspec/vclrfcsharpspec_Start.htm]]
[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]]
[27]
A. Shalit. Dylan Reference Manual. Addison-Wesley, 1996]]
[28]
G. Steele Jr. Common Lisp, the Language. Digital Press, second edition, 1990]]
[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]]
[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]]
[31]
Xerox. The AspectJ programming guide. http://www.aspectj.org/doc/dist/progguide/]]

Cited By

View all
  • (2023)VirtualLoc: Large-scale Visual Localization Using Virtual ImagesACM Transactions on Multimedia Computing, Communications, and Applications10.1145/362278820:3(1-19)Online publication date: 23-Oct-2023
  • (2018)Devirtualizing Memory in Heterogeneous SystemsACM SIGPLAN Notices10.1145/3296957.317319453:2(637-650)Online publication date: 19-Mar-2018
  • (2018)Exploiting Dynamic Thermal Energy Harvesting for Reusing in Smartphone with Mobile ApplicationsACM SIGPLAN Notices10.1145/3296957.317318853:2(243-256)Online publication date: 19-Mar-2018
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 37, Issue 5
May 2002
326 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/543552
Issue’s Table of Contents
  • 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
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
Published in SIGPLAN Volume 37, Issue 5

Check for updates

Author Tags

  1. Java
  2. generative programming
  3. macros
  4. metaprogramming

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)5
  • Downloads (Last 6 weeks)1
Reflects downloads up to 09 Jan 2025

Other Metrics

Citations

Cited By

View all

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media