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.
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsPreview
Unable to display preview. Download preview PDF.
References
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)
Taha, W.: Multi-Stage Programming: Its Theory and Applications. PhD thesis, Oregon Graduate Institute of Science and Technology (1999)
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)
Sheard, T., Benaissa, Z., Martel, M.: Introduction to multi-stage programming using MetaML. Technical report, Pacific Software Research Center, Oregon Graduate Institute (2000)
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)
Hinze, R., Peyton Jones, S.: Derivable type classes. In: Hutton, G. (ed.) Haskell Workshop, Montreal, Canada (2000)
Cheney, J., Hinze, R.: A lightweight implementation of Generics and Dynamics. In: Haskell 2002, Pittsburgh, Pennsylvania, USA (2002)
Sheard, T., Benaissa, Z., Pasalic, E.: DSL implementation using staging and monads. In: Domain-Specific Languages, pp. 81–94 (1999)
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)
Kennedy, A., Syme, D.: Transposing F to C#. In: Proceedings of Workshop on Formal Techniques for Java-like Programs, Málaga, Spain (2002)
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)
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)
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)
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)
Calcagno, C., Taha, W., Huang, L., Leroy, X.: Implementing multi-stage languages using ASTs, Gensym, and Reflection. In: Generative Programming and Component Engineering (2003)
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)
Hornof, L., Jim, T.: Certifying compilation and run-time code generation. In: Partial Evaluation and Semantic-Based Program Manipulation, pp. 60–74 (1999)
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)
Oiwa, Y., Masuhara, H., Yonezawa, A.: DynJava: Type safe dynamic code generation in Java. In: JSST Workshop on Programming and Programming Languages, Tokyo (2001)
Attardi, G., Cisternino, A., Kennedy, A.: CodeBricks: Code fragments as building blocks. In: ACM Symposium on Partial Evaluation and Semantics-Based Program Manipulation (2003)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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