Skip to main content

Reverse Generics: Parametrization after the Fact

  • Conference paper
Software and Data Technologies (ICSOFT 2009)

Part of the book series: Communications in Computer and Information Science ((CCIS,volume 50))

Included in the following conference series:

Abstract

By abstracting over types, generic programming enables one to write code that is independent from specific data type implementation. This style is supported by most mainstream languages, including C++ with templates and Java with generics. If some code is not designed in a generic way from the start, a major effort is required to convert this code to use generic types. This conversion is manually realized which is known to be tedious and error-prone.

We propose Reverse Generics, a general linguistic mechanism to define a generic class from a non-generic class. For a given set of types, a generic is formed by unbinding static dependencies contained in these types. This generalization and generic type instantiation may be done incrementally. This paper studies the possible application of this linguistic mechanism to C++ and Java and, in particular, it reviews limitations of Java generics against our proposal.

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. Allen, E., Bannet, J., Cartwright, R.: A First-Class Approach to Genericity. In: Proc. Of OOPSLA, pp. 96–114. ACM, New York (2003)

    Google Scholar 

  2. Allen, E.E., Cartwright, R.: Safe instantiation in generic java. Sci. Comput. Program. 59(1-2), 26–37 (2006)

    Article  MathSciNet  MATH  Google Scholar 

  3. Abrahams, D., Gurtovoy, A.: C++ Template Metaprogramming: Concepts, Tools and Techniques from Boost and Beyond. Addison-Wesley, Reading (2004)

    Google Scholar 

  4. Alexandrescu, A.: Modern C++ Design, Generic Programming and Design Patterns Applied. Addison Wesley, Reading (2001)

    Google Scholar 

  5. Austern, M.H.: Generic Programming and the STL: using and extending the C++ Standard Template Library. Addison-Wesley, Reading (1998)

    Google Scholar 

  6. Batov, V.: Java generics and C++ templates. C/C++ Users Journal 22(7), 16–21 (2004)

    Google Scholar 

  7. Bracha, G., Odersky, M., Stoutamire, D., Wadler, P.: Making the future safe for the past: adding genericity to the Java programming language. In: Proc. of OOPSLA, pp. 183–200. ACM, New York (1998)

    Google Scholar 

  8. Reis, G.D., Järvi, J.: What is generic programming? In: Proc. of LCSD (2005)

    Google Scholar 

  9. Duggan, D.: Modular type-based reverse engineering of parameterized types in java code. In: Proc. of OOPSLA, pp. 97–113. ACM, New York (1999)

    Google Scholar 

  10. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Reading (1995)

    MATH  Google Scholar 

  11. Ghosh, D.: Generics in Java and C++: a comparative model. ACMSIGPLAN Notices 39(5), 40–47 (2004)

    Article  Google Scholar 

  12. Igarashi, A., Nagira, H.: Union Types for Object Oriented Programming. Journal of Object Technology 6(2), 31–52 (2007)

    Article  Google Scholar 

  13. Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)

    Article  Google Scholar 

  14. Kiezun, A., Ernst, M.D., Tip, F., Fuhrer, R.M.: Refactoring for parameterizing java classes. In: Proc. of ICSE, pp. 437–446. IEEE, Los Alamitos (2007)

    Google Scholar 

  15. Meyer, B.: Eiffel: The Language. Prentice-Hall, Englewood Cliffs (1992)

    MATH  Google Scholar 

  16. Moors, A., Piessens, F., Odersky, M.: Generics of a higher kind. In: Proc. Of OOPSLA, pp. 423–438. ACM, New York (2008)

    Google Scholar 

  17. Musser, D.R., Stepanov, A.A.: Generic programming. In: Gianni, P. (ed.) ISSAC 1988. LNCS, vol. 358, pp. 13–25. Springer, Heidelberg (1989)

    Chapter  Google Scholar 

  18. Musser, D.R., Saini, A.: STL Tutorial and Reference Guide. Addison Wesley, Reading (1996)

    Google Scholar 

  19. Odersky, M., Spoon, L., Venners, B.: Programming in Scala. Artima (2008)

    Google Scholar 

  20. Odersky, M., Wadler, P.: Pizza into Java: Translating theory into practice. In: Proc. of POPL, pp. 146–159. ACM, New York (1997)

    Chapter  Google Scholar 

  21. Siek, J., Taha, W.: A semantic analysis of C++ templates. In: Hu, Q. (ed.) ECOOP 2006. LNCS, vol. 4067, pp. 304–327. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  22. von Dincklage, D., Diwan, A.: Converting Java classes to use generics. In: Proc. of OOPSLA, pp. 1–14. ACM, New York (2004)

    Google Scholar 

  23. Veldhuizen, T.: Using C++ template metaprograms. C++ Report 7(4), 36–43 (1995)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Bergel, A., Bettini, L. (2011). Reverse Generics: Parametrization after the Fact. In: Cordeiro, J., Ranchordas, A., Shishkov, B. (eds) Software and Data Technologies. ICSOFT 2009. Communications in Computer and Information Science, vol 50. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-20116-5_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-20116-5_9

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-20115-8

  • Online ISBN: 978-3-642-20116-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics