A new modular implementation for Stateful Traits - Inria - Institut national de recherche en sciences et technologies du numérique
Article Dans Une Revue Science of Computer Programming Année : 2020

A new modular implementation for Stateful Traits

Résumé

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).
Fichier principal
Vignette du fichier
main.pdf (426.34 Ko) Télécharger le fichier
Origine Fichiers produits par l'(les) auteur(s)
Loading...

Dates et versions

hal-02541842 , version 1 (14-04-2020)

Identifiants

Citer

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

Altmetric

Partager

More