Dynamically typed object-oriented languages have been left out of the scope of generic programming: in a dynamically typed setting, the need for generic programming has been less prominent since no restriction applies over the kind of elements a collection may contain. However, when creating an object, the class name is hardcoded in the program, and this makes the object instantiation process hard to abstract from. In this paper, we describe our implementation of generic programming in Pharo, a Smalltalk dialect, showing how programmers can benefit from generic programming even in a dynamically typed language. 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. As a case study, we show how we used generics and reverse generics in Pharo to reuse unit test cases and to identify a number of bugs and anomalies in the stream class hierarchy. © Springer-Verlag Berlin Heidelberg 2013.
CITATION STYLE
Bergel, A., & Bettini, L. (2013). Generic Programming in Pharo. In Communications in Computer and Information Science (Vol. 411 CCIS, pp. 66–79). Springer Verlag. https://doi.org/10.1007/978-3-642-45404-2_5
Mendeley helps you to discover research relevant for your work.