A Type System for Reflective Program Generators

  • Dirk Draheim
  • Christof Lutteroth
  • Gerald Weber
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 3676)


In this paper we describe a type system for a generative mechanism that generalizes the concept of generic types by combining it with a controlled form of reflection. This mechanism makes many code generation tasks possible for which generic types alone would be insufficient. The power of code generation features are carefully balanced with their safety, so that we are able to perform static type checks on generator code. This leads to a generalized notion of type safety for generators.


Type System Iterative Generation Iterator Variable Execution Error Functional Programming Language 
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.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Draheim, D., Weber, G.: Form-Oriented Analysis - A New Methodology to Model Form-Based Applications. Springer, Heidelberg (2004)Google Scholar
  2. 2.
    Draheim, D., Lutteroth, C., Weber, G.: Factory: Statically Type-Safe Integration of Genericity and Reflection. In: Proceedings of the 4th International Conference on Software Engineering, Artificial Intelligence, Networking, and Parallel/Distributed Computing, ACIS (2003)Google Scholar
  3. 3.
    Draheim, D., Lutteroth, C., Weber, G.: Integrating Code Generators into the C# Language. In: Proceedings of ICITA 2005: The 3rd International Conference on Information Technology and Applications. IEEE Press, Los Alamitos (2005) (to appear)Google Scholar
  4. 4.
    Draheim, D., Lutteroth, C., Weber, G.: Generative Programming for C#. ACM SIGPLAN Notices (2005) (to appear)Google Scholar
  5. 5.
    Kiczales, G.: An overview of AspectJ. In: Knudsen, J.L. (ed.) ECOOP 2001. LNCS, vol. 2072, pp. 18–22. Springer, Heidelberg (2001)Google Scholar
  6. 6.
    Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley, Reading (1995)Google Scholar
  7. 7.
    Kohlbecker, E., Friedman, D., Felleisen, M., Duba, B.: Hygienic Macro Expansion. In: Gabriel, R. (ed.) Proceedings of the ACM SIGPLAN Conference on LISP and Functional Programming, pp. 151–181. ACM Press, New York (1986)Google Scholar
  8. 8.
    Czarnecki, K., Eisenecker, U.: Generative Programming - Methods, Tools, and Applications. Addison-Wesley, Reading (2000)Google Scholar
  9. 9.
    Gabriel, R.G., Bobrow, D.G.: Object Oriented Programming - The CLOS perspective. The MIT Press, Cambridge (1993)Google Scholar
  10. 10.
    Chiba, S.: A Metaobject Protocol for C++. In: OOPSLA 1995 - Proceedings of the 10 th Conference on Object-Oriented Programming Systems, Languages and Programming. SIGPLAN Notices, pp. 285–299. ACM Press, New York (1995)Google Scholar
  11. 11.
    Nizhegorodov, D.: Jasper: Type-Safe MOP-Based Language Extensions and Reflective Template Processing in Java. In: Proceedings of ECOOP 2000 Workshop on Reflection and Metalevel Architectures: State of the Art, and Future Trends. ACM Press, New York (2000)Google Scholar
  12. 12.
    Cardelli, L.: Type Systems. In: Handbook of Computer Science and Engineering. CRC Press, Boca Raton (1997)Google Scholar
  13. 13.
    Bracha, G., Odersky, M., Stoutamire, D., Wadler, P.: Making the future safe for the past: Adding genericity to the Java programming language. In: OOPSLA 1998 - Conference on Object-Oriented Programming Systems, Languages, and Applications. SIGPLAN Notices, pp. 183–200. ACM Press, New York (1998)CrossRefGoogle Scholar
  14. 14.
    Bracha, G., Cohen, N., Kemper, C., Marx, S., Odersky, M., Panitz, S.E., Stoutamire, D., Thorup, K., Wadler, P.: Adding Generics to the Java Programming Language: Participant Draft Specification. Technical report, SUN Microsystems Ltd. (2001)Google Scholar
  15. 15.
    Pierce, B.C.: Types and Programming Languages. MIT Press, Cambridge (2002)Google Scholar
  16. 16.
    Siek, J., Lumsdaine, A.: Concept Checking: Binding Parametric Polymorphism in C++. In: First Workshop on C++ Template Programming, NETOBJECTDAYS 2000 (October 2000)Google Scholar
  17. 17.
    McNamara, B., Smaragdakis, Y.: Static Interfaces in C++. In: First Workshop on C++ Template Programming, NETOBJECTDAYS 2000 (2000)Google Scholar
  18. 18.
    Zólyomi, I., Porkoláb, Z.: Towards a General Template Introspection Library. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, pp. 266–282. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  19. 19.
    Attardi, G., Cisternino, A.: Reflection Support by Means of Template Metaprogramming. In: Bosch, J. (ed.) GCSE 2001. LNCS, vol. 2186, pp. 118–127. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  20. 20.
    Attardi, G., Cisternino, A.: Template Metaprogramming an Object Interface to Relational Tables. In: Yonezawa, A., Matsuoka, S. (eds.) Reflection 2001. LNCS, vol. 2192, p. 266. Springer, Heidelberg (2001)CrossRefGoogle Scholar
  21. 21.
    Smith, D.R.: A Generative Approach to Aspect-Oriented Programming. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, pp. 39–54. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  22. 22.
    Paige, R., Koenig, S.: Finite Differencing of Computable Expressions. ACM Trans. Program. Lang. Syst. 4(3), 402–454 (1982)zbMATHCrossRefGoogle Scholar
  23. 23.
    Smith, B.C.: Reflection and semantics in LISP. In: POPL 1984: Proceedings of the 11th ACM SIGACT-SIGPLAN symposium on Principles of programming languages, pp. 23–35. ACM Press, New York (1984)CrossRefGoogle Scholar
  24. 24.
    Hinze, R., Jeuring, J.: Generic Haskell: Practice and Theory. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 1–56. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  25. 25.
    Hinze, R., Jeuring, J.: Generic Haskell: Applications. In: Backhouse, R., Gibbons, J. (eds.) Generic Programming. LNCS, vol. 2793, pp. 57–96. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  26. 26.
    Kiczales, G., des Rivières, J.: The Art of the Metaobject Protocol. MIT Press, Cambridge (1991)Google Scholar
  27. 27.
    von Dincklage, D.: Making Patterns Explicit with Metaprogramming. In: Pfenning, F., Smaragdakis, Y. (eds.) GPCE 2003. LNCS, vol. 2830, pp. 287–306. Springer, Heidelberg (2003)CrossRefGoogle Scholar
  28. 28.
    Taha, W., Sheard, T.: Multi-Stage Programming with Explicit Annotations. In: PEPM 1997 - Partial Evaluation and Semantics-Based Program Manipulation. SIPLAN Notices, pp. 203–217. ACM Press, New York (1997)CrossRefGoogle Scholar
  29. 29.
    Taha, W., Sheard, T.: MetaML and Multi-stage Programming with Explicit Annotations. Theoretical Computer Science 248, 211–242 (2000)zbMATHCrossRefGoogle Scholar
  30. 30.
    Leroy, X., Doligez, D., Garrigue, J., Rémy, D., Vouillon, J.: The Objective Caml system release 3.08 - Documentation and user’s manual. Technical report, Institut National de Recherche en Informatique et en Automatique (2004)Google Scholar
  31. 31.
    Neverov, G., Roe, P.: Metaphor: A Multi-stage, Object-Oriented Programming Language. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, pp. 168–185. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  32. 32.
    Draheim, D., Lutteroth, C., Weber, G.: An Analytical Comparison of Generative Programming Technologies. Technical Report B-04-02, Institute of Computer Science, Freie Universität Berlin (2004)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2005

Authors and Affiliations

  • Dirk Draheim
    • 1
  • Christof Lutteroth
    • 2
  • Gerald Weber
    • 2
  1. 1.Institute of Computer ScienceFreie Universität BerlinBerlinGermany
  2. 2.Department of Computer ScienceThe University of AucklandAucklandNew Zealand

Personalised recommendations