Skip to Main content Skip to Navigation
Journal articles

A new modular implementation for Stateful Traits

Abstract : The term traits is overloaded in the literature. In this work we refer to traits as the stateless model and implementation described in Schaerli et al. articles. Traits provide a flexible way to support multiple inheritance code reuse in the context of a single inheritance language. The Pharo programming language includes the second implementation of stateless traits based on the original version of Schaerli's one. Even if it is the second iteration of such an implementation, it presents several limitations. First, it does not support state in traits. Second, its implementation is monolithic i.e., it is deeply coupled with the rest of the language kernel: it cannot be loaded nor unloaded. Furthermore, trait support impacts all classes, even classes not using traits. In addition, while the development tools include full support to work with classes, trait support is more limited because classes and traits do not present the same Metaobject Protocol (MOP). Finally, being monolithic and integrated in the language kernel, it is difficult to extend this current implementation. This article describes a new modular and extensible implementation of traits: it is easily loadable and unloadable as any other package. In addition, classes not using traits are not impacted. Finally, this new implementation includes a new and carefully designed Metaobject Protocol (MOP) that is compatible with both classes and traits. This allows one to reuse existing tools as they do not require special support for traits. Then, following the semantics proposed for stateful traits in [BDNW07], we present a new implementation of stateful traits. This implementation is an extension of our new modular implementation. We implemented modular traits using specialized metaclasses as our main language extension mechanism. By replacing the implementation we reduced the Pharo Language Kernel size by 15%. This model and implementation are used in production since Pharo7.0 (January 2019).
Document type :
Journal articles
Complete list of metadata

Cited literature [49 references]  Display  Hide  Download
Contributor : Lse Lse Connect in order to contact the contributor
Submitted on : Tuesday, April 14, 2020 - 11:09:46 AM
Last modification on : Friday, January 21, 2022 - 3:12:35 AM


Files produced by the author(s)



Pablo Tesone, Stéphane Ducasse, Guillermo Polito, Luc Fabresse, Noury Bouraqadi. A new modular implementation for Stateful Traits. Science of Computer Programming, Elsevier, 2020, 195, ⟨10.1016/j.scico.2020.102470⟩. ⟨hal-02541842⟩



Les métriques sont temporairement indisponibles