Create a trait:

Trait named: #ABBA
        uses: {}
        category: 'ABBA'.

- add a method #foo to ABBA trait

Then create 2 classes which using it:

Object subclass: #ABBAB
        uses: ABBA
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'ABBA'.

Object subclass: #ABBAC
        uses: ABBA
        instanceVariableNames: ''
        classVariableNames: ''
        poolDictionaries: ''
        category: 'ABBA'.


now what i found interesting:

(ABBAB methodDict at: #foo) == (ABBAC methodDict at: #foo)

but as side effect, we got this one:

(ABBAB methodDict at: #foo) methodClass  ==> ABBAC

which i find a bit disturbing :(

I'm not sure if given issue could have a major impact somewhere...
But i would just #clone the trait method before installing it..
Yes, it takes more space, but it makes each of such methods unrelated.

And i strongly assume that these methods should be unrelated, and
moreover, recompiled for each class separately, because
global var in one class could be a class var in another one, so a
trait method, like:

foo
  ^ Bar

will behave depending on class environment.


-- 
Best regards,
Igor Stasenko AKA sig.

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to