Skip to main content

Metaphor: A Multi-stage, Object-Oriented Programming Language

  • Conference paper
Book cover Generative Programming and Component Engineering (GPCE 2004)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 3286))

Abstract

This paper presents a language (called Metaphor) for expressing staged programs in a strongly-typed, imperative, object-oriented environment. The language is based on a subset of C# or Java; it is multi-stage and provides static type checking of later stage code. Object-oriented frameworks usually offer a type introspection or reflection capability to discover information about types at run-time. Metaphor allows this reflection system to be incorporated into the language’s staging constructs, thus allowing the generation of code based on the structure of types – a common application for code generation in these environments. The paper presents the language, gives a formal description of its type system and discusses a prototype implementation of the language as a compiler targeting the .NET Common Language Runtime.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Taha, W., Sheard, T.: Multi-stage programming with explicit annotations. In: Partial Evaluation and Semantics-Based Program Manipulation, Amsterdam, The Netherlands, June 1997, pp. 203–217. ACM, New York (1997)

    Chapter  Google Scholar 

  2. Taha, W.: Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology (1999)

    Google Scholar 

  3. Sheard, T.: Accomplishments and research challenges in meta-programming. In: Taha, W. (ed.) SAIG 2001. LNCS, vol. 2196, p. 2. Springer, Heidelberg (2001) (invited talk)

    Chapter  Google Scholar 

  4. Sheard, T., Benaissa, Z., Martel, M.: Introduction to multi-stage programming using MetaML. Technical report, Pacific Software Research Center, Oregon Graduate Institute (2000)

    Google Scholar 

  5. Jansson, P., Jeuring, J.: PolyP – A polytypic programming language extension. In: ACM Symposium on Principles of Programming Languages, POPL 1997, Paris, France, January 15-17, pp. 470–482. ACM Press, New York (1997)

    Chapter  Google Scholar 

  6. Hinze, R., Peyton Jones, S.: Derivable type classes. In: Hutton, G. (ed.) Haskell Workshop, Montreal, Canada (2000)

    Google Scholar 

  7. Cheney, J., Hinze, R.: A lightweight implementation of Generics and Dynamics. In: Haskell 2002, Pittsburgh, Pennsylvania, USA (2002)

    Google Scholar 

  8. Sheard, T., Benaissa, Z., Pasalic, E.: DSL implementation using staging and monads. In: Domain-Specific Languages, pp. 81–94 (1999)

    Google Scholar 

  9. Igarashi, A., Pierce, B., Wadler, P.: Featherweight Java: A minimal core calculus for Java and GJ. In: Meissner, L. (ed.) Proceedings of the 1999 ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages & Applications (OOPSLA 1999), N. Y, vol. 34(10), pp. 132–146 (1999)

    Google Scholar 

  10. Kennedy, A., Syme, D.: Transposing F to C#. In: Proceedings of Workshop on Formal Techniques for Java-like Programs, Málaga, Spain (2002)

    Google Scholar 

  11. Calcagno, C., Moggi, E., Taha, W.: Closed types as a simple approach to safe imperative multi-stage programming. In: Automata, Languages and Programming, pp. 25–36 (2000)

    Google Scholar 

  12. Taha, W., Nielsen, M.F.: Environment classifiers. In: Proceedings of the 30th ACM Symposium on Principles of Programming Languages (POPL 2003), New Orleans, Louisiana, ACM Press, New York (2003)

    Google Scholar 

  13. Calcagno, C., Moggi, E., Taha, W.: ML-like inference for classifiers. In: Schmidt, D. (ed.) ESOP 2004. LNCS, vol. 2986, pp. 79–93. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  14. Sheard, T., Peyton Jones, S.: Template metaprogramming for Haskell. In: Chakravarty, M. (ed.) ACM SIGPLAN Haskell Workshop 2002, pp. 1–16. ACM Press, New York (2002)

    Chapter  Google Scholar 

  15. Calcagno, C., Taha, W., Huang, L., Leroy, X.: Implementing multi-stage languages using ASTs, Gensym, and Reflection. In: Generative Programming and Component Engineering (2003)

    Google Scholar 

  16. Engler, D.R., Hsieh, W.C., Kaashoek, M.F.: ´C: A language for high-level, efficient, and machine-independent dynamic code generation. In: Symposium on Principles of Programming Languages, pp. 131–144 (1996)

    Google Scholar 

  17. Hornof, L., Jim, T.: Certifying compilation and run-time code generation. In: Partial Evaluation and Semantic-Based Program Manipulation, pp. 60–74 (1999)

    Google Scholar 

  18. Jim, T., Morrisett, G., Grossman, D., Hicks, M., Cheney, J., Wang, Y.: Cyclone: A safe dialect of C. In: USENIX Annual Technical Conference, Monterey, CA, June 2002 (2002)

    Google Scholar 

  19. Oiwa, Y., Masuhara, H., Yonezawa, A.: DynJava: Type safe dynamic code generation in Java. In: JSST Workshop on Programming and Programming Languages, Tokyo (2001)

    Google Scholar 

  20. Attardi, G., Cisternino, A., Kennedy, A.: CodeBricks: Code fragments as building blocks. In: ACM Symposium on Partial Evaluation and Semantics-Based Program Manipulation (2003)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2004 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Neverov, G., Roe, P. (2004). Metaphor: A Multi-stage, Object-Oriented Programming Language. In: Karsai, G., Visser, E. (eds) Generative Programming and Component Engineering. GPCE 2004. Lecture Notes in Computer Science, vol 3286. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-30175-2_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-30175-2_9

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-23580-4

  • Online ISBN: 978-3-540-30175-2

  • eBook Packages: Springer Book Archive

Publish with us

Policies and ethics