Affiliation:
1. LogicBlox, Inc., Atlanta, GA
2. University of Massachusetts, Amherst, MA
Abstract
We present MorphJ: a language for specifying general classes whose members are produced by iterating over members of other classes. We call this technique “class morphing” or just “morphing.” Morphing extends the notion of genericity so that not only types of methods and fields, but also the
structure
of a class can vary according to type variables. This adds a disciplined form of metaprogramming to mainstream languages and allows expressing common programming patterns in a highly generic way that is otherwise not supported by conventional techniques. For instance, morphing lets us write generic proxies (i.e., classes that can be parameterized with another class and export the same public methods as that class); default implementations (e.g., a generic do-nothing type, configurable for any interface); semantic extensions (e.g., specialized behavior for methods that declare a certain annotation); and more. MorphJ's hallmark feature is that, despite its emphasis on generality, it allows modular type-checking: a MorphJ class can be checked independently of its uses. Thus, the possibility of supplying a type parameter that will lead to invalid code is detected early, an invaluable feature for highly general components that will be statically instantiated by other programmers. We demonstrate the benefits of morphing with several examples, including a MorphJ reimplementation of DSTM2, a software transactional memory library which reduces 1,484 lines of Java reflection and bytecode engineering library calls to just 586 lines of MorphJ code.
Funder
Division of Computing and Communication Foundations
Publisher
Association for Computing Machinery (ACM)
Reference46 articles.
1. A first-class approach to genericity
2. Apache Software Foundation. Byte-code engineering library. http://jakarta.apache.org/bcel/manual.html. (6/09). Apache Software Foundation. Byte-code engineering library. http://jakarta.apache.org/bcel/manual.html. (6/09).
3. The Java syntactic extender (JSE)
4. Maya
Cited by
14 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. A Survey of Metaprogramming Languages;ACM Computing Surveys;2020-11-30
2. Meta C++: an extension layer for multi-stage generative metaprogramming .;The Journal of Object Technology;2019
3. Efficient Reusable Collections;IEICE Transactions on Information and Systems;2018-11-01
4. Unifying analytic and statically-typed quasiquotes;Proceedings of the ACM on Programming Languages;2018-01
5. Structured Program Generation Techniques;Lecture Notes in Computer Science;2017