User-Changeable Visibility: Resolving Unanticipated Name Clashes in Traits

Abstract : A trait is a unit of behaviour that can be composed with other traits and used by classes. Traits offer an alternative to multiple inheritance. Conflict resolution of traits, while flexible, does not completely handle accidental method name conflicts: if a trait with method m is composed with another trait defining a different method m then resolving the conflict may prove delicate or infeasible in cases where both versions of m are still needed. In this paper we present freezeable traits, which provide an expressive composition mechanism to support unanticipated method composition conflicts. Our solution introduces private trait methods and lets the class composer change method visibility at composition time (from public to private and vice versa). Moreover two class composers may use different composition policies for the same trait, something which is not possible in mainstream languages. This approach respects the two main design principles of traits: the class composer is empowered and traits can be flattened away. We present an implementation of freezable traits in Smalltalk. As a side-effect of this implementation we introduced private (early-bound and invisible) methods to Smalltalk by distinguishing object-sends from self-sends. Our implementation uses compile-time bytecode manipulation and, as such, introduces no run-time penalties.
Type de document :
Communication dans un congrès
Proceedings of 22nd International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'07), 2008, Montreal, Canada. 2008
Liste complète des métadonnées

https://hal.inria.fr/inria-00216103
Contributeur : Lse Lse <>
Soumis le : jeudi 24 janvier 2008 - 14:48:31
Dernière modification le : jeudi 11 janvier 2018 - 06:19:48

Identifiants

  • HAL Id : inria-00216103, version 1

Collections

Citation

Stéphane Ducasse, Oscar Nierstrasz, Roel Wuyts, Alexandre Bergel. User-Changeable Visibility: Resolving Unanticipated Name Clashes in Traits. Proceedings of 22nd International Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA'07), 2008, Montreal, Canada. 2008. 〈inria-00216103〉

Partager

Métriques

Consultations de la notice

212