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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
Allen, E., Bannet, J., Cartwright, R.: A First-Class Approach to Genericity. In: Proc. Of OOPSLA, pp. 96–114. ACM, New York (2003)
Allen, E.E., Cartwright, R.: Safe instantiation in generic java. Sci. Comput. Program. 59(1-2), 26–37 (2006)
Abrahams, D., Gurtovoy, A.: C++ Template Metaprogramming: Concepts, Tools and Techniques from Boost and Beyond. Addison-Wesley, Reading (2004)
Alexandrescu, A.: Modern C++ Design, Generic Programming and Design Patterns Applied. Addison Wesley, Reading (2001)
Austern, M.H.: Generic Programming and the STL: using and extending the C++ Standard Template Library. Addison-Wesley, Reading (1998)
Batov, V.: Java generics and C++ templates. C/C++ Users Journal 22(7), 16–21 (2004)
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)
Reis, G.D., Järvi, J.: What is generic programming? In: Proc. of LCSD (2005)
Duggan, D.: Modular type-based reverse engineering of parameterized types in java code. In: Proc. of OOPSLA, pp. 97–113. ACM, New York (1999)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Reading (1995)
Ghosh, D.: Generics in Java and C++: a comparative model. ACMSIGPLAN Notices 39(5), 40–47 (2004)
Igarashi, A., Nagira, H.: Union Types for Object Oriented Programming. Journal of Object Technology 6(2), 31–52 (2007)
Igarashi, A., Pierce, B.C., Wadler, P.: Featherweight Java: a minimal core calculus for Java and GJ. ACM TOPLAS 23(3), 396–450 (2001)
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)
Meyer, B.: Eiffel: The Language. Prentice-Hall, Englewood Cliffs (1992)
Moors, A., Piessens, F., Odersky, M.: Generics of a higher kind. In: Proc. Of OOPSLA, pp. 423–438. ACM, New York (2008)
Musser, D.R., Stepanov, A.A.: Generic programming. In: Gianni, P. (ed.) ISSAC 1988. LNCS, vol. 358, pp. 13–25. Springer, Heidelberg (1989)
Musser, D.R., Saini, A.: STL Tutorial and Reference Guide. Addison Wesley, Reading (1996)
Odersky, M., Spoon, L., Venners, B.: Programming in Scala. Artima (2008)
Odersky, M., Wadler, P.: Pizza into Java: Translating theory into practice. In: Proc. of POPL, pp. 146–159. ACM, New York (1997)
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)
von Dincklage, D., Diwan, A.: Converting Java classes to use generics. In: Proc. of OOPSLA, pp. 1–14. ACM, New York (2004)
Veldhuizen, T.: Using C++ template metaprograms. C++ Report 7(4), 36–43 (1995)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)