[go: up one dir, main page]
More Web Proxy on the site http://driver.im/ skip to main content
10.1145/1173706.1173748acmconferencesArticle/Chapter ViewAbstractPublication PagesgpceConference Proceedingsconference-collections
Article

Reflective program generation with patterns

Published: 22 October 2006 Publication History

Abstract

Runtime reflection facilities, as present in Java and .NET, are powerful mechanisms for inspecting existing code and metadata, as well as generating new code and metadata on the fly. Such power does come at a high price though. The runtime reflection support in Java and .NET imposes a cost on all programs, whether they use reflection or not, simply by the necessity of keeping all metadata around and the inability to optimize code because of future possible code changes. A second---often overlooked---cost is the difficulty of writing correct reflection code to inspect or emit new metadata and code and the risk that the emitted code is not well-formed.In this paper we examine a subclass of problems that can be addressed using a simpler mechanism than runtime reflection, which we call compile-time reflection. We argue for a high-level construct called a transform that allows programmers to write inspection and generation code in a pattern matching and template style, avoiding at the same time the complexities of reflection APIs and providing the benefits of staged compilation in that the generated code and metadata is known to be well-formed and type safe ahead of time.

References

[1]
Partition III: CIL Instruction Set. ECMA Standard 335 http://www.ecma-international.org/publications/standards/Ecma-335.htm.
[2]
American National Standards Institute. ANSI/ISO/IEC 9899-1999: Programming Languages --- C. American National Standards Institute, 1430 Broadway, New York, NY 10018, USA, 1999.
[3]
Don Chamberlin. XQuery: A Query Language for XML. In SIGMOD '03: Proceedings of the 2003 ACM SIGMOD international conference on Management of data, pages 682--682, New York, NY, USA, 2003. ACM Press.
[4]
Shigeru Chiba. A metaobject protocol for C++. In ACM Conference on Object-Oriented Programming Systems, Languages, and Applications (OOPSLA'95), SIGPLAN Notices 30(10), pages 285--299, Austin, Texas, USA, October 1995.
[5]
Dirk Draheim, Christof Lutteroth, and Gerald Weber. A type system for reflective program generators. In Glück and Lowry {7}, pages 327--341.
[6]
Steven Ganz, Amr Sabry, and Walid Taha. Macros as multi-stage computations: Type-safe, generative, binding macros in MacroML. In the International Conference on Functional Programming (ICFP '01), Florence, Italy, September 2001.
[7]
Robert Glück and Michael R. Lowry, editors. Proceedings of the 4th International Conference on Generative Programming and Component Engineering, volume 3676 of Lecture Notes in Computer Science. Springer, September 2005.
[8]
Maurice Herlihy. SXM: C\# Software Transactional Memory. http://www.cs.brown.edu/~mph/SXM/, May 2005.
[9]
J. Hook and T. Sheard. A semantics of compile-time reflection. Technical Report 93-019, Department of Computer Science and Engineering, Oregon Graduate Institute, 1993.
[10]
Haruo Hosoya, Alain Frisch, and Giuseppe Castagna. Parametric polymorphism for XML. In POPL '05: Proceedings of the 32nd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pages 50--62, New York, NY, USA, 2005. ACM Press.
[11]
Shan Shan Huang, David Zook, and Yannis Smaragdakis. Statically safe program generation with SafeGen. In Glück and Lowry {7}, pages 309--326.
[12]
Galen Hunt, James Larus, Martín Abadi, Mark Aiken, Paul Barham, Manuel Fähndrich, Chris Hawblitzel, Orion Hodson, Steven Levi, Nick Murphy, Bjarne Steensgaard, David Tarditi, Ted Wobber, and Brian Zill. An Overview of the Singularity Project. Technical Report MSR-TR-2005-135, Microsoft Research, 2005.
[13]
Sam Kamin. Routine run-time code generation. In Proceedings of 2003 ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'03), pages 208--220, October 2003.
[14]
Andrew Kennedy and Don Syme. Design and Implementation of Generics for the .NET Common Language Runtime. In PLDI '01: Proceedings of the ACM SIGPLAN 2001 Conference on Programming Language Design and Implementation, pages 1--12, 2001.
[15]
Gregor Kiczales, Erik Hilsdale, Jim Hugunin, Mik Kersten, Jeffrey Palm, and William G. Griswold. An overview of AspectJ. Lecture Notes in Computer Science, 2072:327--355, 2001.
[16]
Gregor Kiczales, John Lamping, Anurag Menhdhekar, Chris Maeda, Cristina Lopes, Jean-Marc Loingtier, and John Irwin. Aspect-oriented programming. In Mehmet Akşit and Satoshi Matsuoka, editors, Proceedings European Conference on Object-Oriented Programming, volume 1241, pages 220--242. Springer-Verlag, Berlin, Heidelberg, and New York, 1997.
[17]
Gregor Kiczales and Jim Des Rivieres. The Art of the Metaobject Protocol. MIT Press, Cambridge, MA, USA, 1991.
[18]
Xavier Leroy. A modular module system. Journal of Functional Programming, 10(3):269--303, 2000.
[19]
Emir Pašalić, Walid Taha, and Tim Sheard. Tagless staged interpreters for typed languages. In the International Conference on Functional Programming (ICFP '02), Pittsburgh, USA, October 2002.
[20]
Massimiliano Poletto, Wilson C. Hsieh, Dawson R. Engler, and M. Frans Kaashoek. `C and tcc: A language and compiler for dynamic code generation. ACM Transactions on Programming Languages and Systems, 21(2):324--369, March 1999.
[21]
Michael Spear, Tom Roeder, Orion Hodson, Galen Hunt, and Steven Levi. Solving the Starting Problem: Device Drivers as Self-Describing Artifacts. In Proceedings of the Eurosys 2006 Conference, pages 45--57, Leuven, Belgium, April 2006. ACM.
[22]
W. Taha and T. Sheard. Multi-stage programming with explicit annotations. In Partial Evaluation and Semantics-Based Program Manipulation, Amsterdam, The Netherlands, June 1997, pages 203--217. New York: ACM, 1997.
[23]
Walid Taha. A sound reduction semantics for untyped CBN multi-stage computation. Or, the theory of MetaML is non-trivial. In Proceedings of the Workshop on Partial Evaluation and Semantics-Based Program Manipulation (PEPM), Boston, 2000.
[24]
Malte Appeltauer Tobias Rho, Günter Kniesel. Fine-grained generic aspects, workshop on foundations of aspect-oriented languages (foal'06), aosd 2006. Workshop on Foundations of Aspect-Oriented Languages (FOAL'06), in conjunction with Fifth International Conference on Aspect-Oriented Software Development (AOSD.06), March 20-24, 2006, Bonn, Germany, Mar 2006.

Cited By

View all
  • (2019)Refinement kinds: type-safe programming with practical type-level computationProceedings of the ACM on Programming Languages10.1145/33605573:OOPSLA(1-30)Online publication date: 10-Oct-2019
  • (2017)Structured Program Generation TechniquesGrand Timely Topics in Software Engineering10.1007/978-3-319-60074-1_7(154-178)Online publication date: 29-Jun-2017
  • (2015)Reusing metadata across components, applications, and languagesScience of Computer Programming10.1016/j.scico.2014.09.00298:P4(617-644)Online publication date: 1-Feb-2015
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
GPCE '06: Proceedings of the 5th international conference on Generative programming and component engineering
October 2006
310 pages
ISBN:1595932372
DOI:10.1145/1173706
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]

Sponsors

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 22 October 2006

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. generative programming
  2. patterns
  3. reflection
  4. templates

Qualifiers

  • Article

Conference

GPCE06
Sponsor:
GPCE06: Generative Programming and Component Engineering 2006
October 22 - 26, 2006
Oregon, Portland, USA

Acceptance Rates

Overall Acceptance Rate 56 of 180 submissions, 31%

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)4
  • Downloads (Last 6 weeks)0
Reflects downloads up to 06 Jan 2025

Other Metrics

Citations

Cited By

View all
  • (2019)Refinement kinds: type-safe programming with practical type-level computationProceedings of the ACM on Programming Languages10.1145/33605573:OOPSLA(1-30)Online publication date: 10-Oct-2019
  • (2017)Structured Program Generation TechniquesGrand Timely Topics in Software Engineering10.1007/978-3-319-60074-1_7(154-178)Online publication date: 29-Jun-2017
  • (2015)Reusing metadata across components, applications, and languagesScience of Computer Programming10.1016/j.scico.2014.09.00298:P4(617-644)Online publication date: 1-Feb-2015
  • (2014)Compile-time reflection and metaprogramming for JavaProceedings of the ACM SIGPLAN 2014 Workshop on Partial Evaluation and Program Manipulation10.1145/2543728.2543739(27-37)Online publication date: 11-Jan-2014
  • (2014)Extending Type Inference to Variational ProgramsACM Transactions on Programming Languages and Systems10.1145/251819036:1(1-54)Online publication date: 1-Mar-2014
  • (2012)Metadata invariants: checking and inferring metadata coding conventionsProceedings of the 34th International Conference on Software Engineering10.5555/2337223.2337305(694-704)Online publication date: 2-Jun-2012
  • (2012)Pattern-based traitsProceedings of the 27th Annual ACM Symposium on Applied Computing10.1145/2245276.2232057(1729-1736)Online publication date: 26-Mar-2012
  • (2012)Metadata invariants: Checking and inferring metadata coding conventions2012 34th International Conference on Software Engineering (ICSE)10.1109/ICSE.2012.6227148(694-704)Online publication date: Jun-2012
  • (2012)POET: a scripting language for applying parameterized source-to-source program transformationsSoftware—Practice & Experience10.1002/spe.108942:6(675-706)Online publication date: 1-Jun-2012
  • (2011)MorphingACM Transactions on Programming Languages and Systems10.1145/1890028.189002933:2(1-44)Online publication date: 7-Feb-2011
  • Show More Cited By

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