Capítulo de livro Revisado por pares

Reverse Generics: Parametrization after the Fact

2011; Springer Science+Business Media; Linguagem: Inglês

10.1007/978-3-642-20116-5_9

ISSN

1865-0937

Autores

Alexandre Bergel, Lorenzo Bettini,

Tópico(s)

Parallel Computing and Optimization Techniques

Resumo

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.

Referência(s)