Generics and Reverse Generics for Pharo
Alexandre Bergel, Lorenzo Bettini
2012
Abstract
Generic programming is a mechanism for re-using code by abstracting specific types used in classes and programs. In this paper, we present a mechanism for adding generic programming in dynamically typed languages, showing how programmers can benefit from generic programming. Furthermore, we enhance the expressiveness of generic programming with reverse generics, a mechanism for automatically deriving new generic code starting from existing non-generic one. We implemented generics and reverse generics in Pharo Smalltalk, and we successfully used them to solve a problem of reusing unit test cases. This helped us to identify a number of bugs and anomalies in the stream class hierarchy.
References
- Abrahams, D. and Gurtovoy, A. (2004). C++ Template Metaprogramming: Concepts, Tools and Techniques from Boost and Beyond. Addison-Wesley.
- Allen, E., Bannet, J., and Cartwright, R. (2003). A FirstClass Approach to Genericity. In OOPSLA, pages 96- 114. ACM.
- Allen, E. and Cartwright, R. (2002). The Case for Run-time Types in Generic Java. In PPPJ, pages 19-24. ACM.
- Austern, M. H. (1998). Generic Programming and the STL: using and extending the C++ Standard Template Library. Addison-Wesley.
- Axelsen, E. W. and Krogdahl, S. (2009). Groovy package templates: supporting reuse and runtime adaption of class hierarchies. In DLS, pages 15-26. ACM.
- Batov, V. (2004). Java generics and C++ templates. C/C++ Users Journal, 22(7):16-21.
- Bergel, A. and Bettini, L. (2011). Reverse Generics: Parametrization after the Fact. In Software and Data Technologies, volume 50 of CCIS, pages 107-123. Springer.
- Bergel, A., Ducasse, S., and Nierstrasz, O. (2005). Classbox/J: Controlling the Scope of Change in Java. In OOPSLA, pages 177-189. ACM.
- Bracha, G., Odersky, M., Stoutamire, D., and Wadler, P. (1998). Making the future safe for the past: adding genericity to the Java programming language. In OOPSLA, pages 183-200. ACM.
- Bracha, G., von der Ahé, P., Bykov, V., Kashai, Y., Maddox, W., and Miranda, E. (2010). Modules as Objects in Newspeak. In ECOOP, pages 405-428. Springer.
- Cohen, T. and Gil, J. (2007). Better Construction with Factories. JOT, 6(6):103-123.
- Dincklage, D. V. and Diwan, A. (2004). Converting Java classes to use generics. In OOPSLA, pages 1-14. ACM.
- Ducasse, S., Nierstrasz, O., Schärli, N., Wuyts, R., and Black, A. P. (2006). Traits: A Mechanism for finegrained Reuse. ACM TOPLAS, 28(2):331-388.
- Ducasse, S., Pollet, D., Bergel, A., and Cassou, D. (2009). Reusing and Composing Tests with Traits. In TOOLS, volume 33 of LNBIP, pages 252-271. Springer.
- Duggan, D. (1999). Modular type-based reverse engineering of parameterized types in Java code. In OOPSLA, pages 97-113. ACM.
- Eisenecker, U. W. and Czarnecki, K. (2000). Generative Programming: Methods, Tools, and Applications. Addison-Wesley.
- Flatt, M. and Felleisen, M. (1998). Units: Cool Modules for HOT Languages. In PLDI, pages 236-248. ACM.
- Fowler, M. (2004). Inversion of Control Containers and the Dependency Injection pattern. http://www.martinfowler.com/articles/injection.html.
- Gamma, E., Helm, R., Johnson, R., and Vlissides, J. (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley.
- Ghosh, D. (2004). Generics in Java and C++: a comparative model. ACM SIGPLAN Notices, 39(5):40-47.
- Goldberg, A. and Robson, D. (1983). Smalltalk 80: the Language and its Implementation. Addison-Wesley.
- Kapur, D., Musser, D. R., and Stepanov, A. A. (1981). Tecton: A Language for Manipulating Generic Objects. In Program Specification, volume 134 of LNCS, pages 402-414. Springer.
- Kiezun, A., Ernst, M. D., Tip, F., and Fuhrer, R. M. (2007). Refactoring for Parameterizing Java Classes. In ICSE, pages 437-446. IEEE.
- Lienhard, A. (2004). Bootstrapping Traits. Master's thesis, University of Bern.
- Moors, A., Piessens, F., and Odersky, M. (2008). Generics of a higher kind. In OOPSLA, pages 423-438. ACM.
- Odersky, M., Spoon, L., and Venners, B. (2008). Programming in Scala. Artima.
- Odersky, M. and Wadler, P. (1997). Pizza into Java: Translating theory into practice. In POPL, pages 146-159. ACM.
- Reppy, J. and Turon, A. (2007). Metaprogramming with Traits. In ECOOP, volume 4609 of LNCS, pages 373- 398. Springer.
- Siek, J. and Taha, W. (2006). A semantic analysis of C++ templates. In ECOOP, volume 4067 of LNCS, pages 304-327. Springer.
- Sørensen, F., Axelsen, E. W., and Krogdahl, S. (2010). Reuse and combination with package templates. In MASPEGHI, pages 1-5. ACM.
- Weiss, R. and Simonis, V. (2001). Exploring template template parameters. In Perspectives of System Informatics, volume 2244 of LNCS, pages 500-510. Springer.
Paper Citation
in Harvard Style
Bergel A. and Bettini L. (2012). Generics and Reverse Generics for Pharo . In Proceedings of the 7th International Conference on Software Paradigm Trends - Volume 1: ICSOFT, ISBN 978-989-8565-19-8, pages 363-372. DOI: 10.5220/0004027503630372
in Bibtex Style
@conference{icsoft12,
author={Alexandre Bergel and Lorenzo Bettini},
title={Generics and Reverse Generics for Pharo},
booktitle={Proceedings of the 7th International Conference on Software Paradigm Trends - Volume 1: ICSOFT,},
year={2012},
pages={363-372},
publisher={SciTePress},
organization={INSTICC},
doi={10.5220/0004027503630372},
isbn={978-989-8565-19-8},
}
in EndNote Style
TY - CONF
JO - Proceedings of the 7th International Conference on Software Paradigm Trends - Volume 1: ICSOFT,
TI - Generics and Reverse Generics for Pharo
SN - 978-989-8565-19-8
AU - Bergel A.
AU - Bettini L.
PY - 2012
SP - 363
EP - 372
DO - 10.5220/0004027503630372