Hi I have been working on a new API to access class, traits, selector for traits I wrote some tests in the PharoTaskForces/Traits-MOPTests package Now in essence we have - The selector of a compiled method should be its name. An aliased method should have the name of its alias name. - The class of a compiled method is the class that contains it. A compiled method cannot be shared. - The origin of a compiledMethod is its defining class or trait. - The reachHome of a compiled method is class or traits that you changed (and not override) when you want to change a method in the flat view. T1 c c1 T2 c c3 uses: T1 Class A foo uses: T2 testSelectorT11T2 "self debug: #testSelectorT11T2" "The selector of a compiled method should be its name. An aliased method should have the name of its alias name." self assert: (AUsingTrait2>>#foo) selector = #foo. self assert: (Trait1>>#c) selector = #c. self assert: (Trait2>>#c) selector = #c. self assert: (AUsingTrait2>>#c) selector = #c. self assert: (AUsingTrait2>>#c3) selector = #c2. self assert: (BUsingTrait1>>#c) selector = #c. testClassT11T2 "The class of a compiled method is the class that contains it. A compiled method cannot be shared." self assert: (AUsingTrait2>>#foo) methodClass = AUsingTrait2. self assert: (AUsingTrait2>>#c) methodClass = AUsingTrait2. self assert: (AUsingTrait1>>#c3) methodClass = AUsingTrait2. self assert: (AUsingTrait2>>#c1) methodClass = AUsingTrait2. self assert: (BUsingTrait1>>#c) methodClass = BUsingTrait1. self should: (Trait1>>#c1) methodClass = nil. "T1 or nil" self should: (Trait2>>#c2) methodClass = nil. "T2 or nil" self should: (Trait2>>#c1) methodClass = nil. "T2 or nil or T1" testReachHome "self debug: #testReachHome" " The reachHome is the method that you changed (and not override) when you want to change a method in the flat view." self assert: (AUsingTrait2>>#foo) reachHome = AUsingTrait2. self assert: (AUsingTrait2>>#c3) reachHome = Trait2. self assert: (AUsingTrait2>>#c1) reachHome = Trait1. self assert: (AUsingTrait2>>#c) reachHome = Trait2. self assert: (Trait11>>#c) reachHome = Trait11. self assert: (Trait2>>#c) reachHome = Trait2. self assert: (Trait2>>#c1) reachHome = Trait11. self assert: (AUsingTrait1>>#c2) reachHome = AUsingTrait1. testOrigin "self debug: #testClass" "The origin of a compiledMethod is its defining class or trait." self assert: (AUsingTrait2>>#foo) origin = AUsingTrait2. self assert: (AUsingTrait2>>#c3) origin = Trait2. self assert: (AUsingTrait2>>#c1) origin = Trait11. self assert: (AUsingTrait2>>#c) origin = Trait11. self assert: (BUsingTrait1>>#c) origin = Trait1. self assert: (Trait2>>#c3) origin = Trait2. self assert: (Trait11>>#c1) origin = Trait11. self assert: (Trait2>>#c1) origin = Trait11. "since it introduced the alias it is its origin" self assert: (AUsingTrait1>>#c2) origin = AUsingTrait1. testTraitT11T2 "it seems to me that we do not need trait: but we need origin and reachHome" "(A>>foo) trait -> nil (A>>c3) trait -> T2 (A>>c) trait -> T2 (A>>c1) trait -> T2 ***** since it is flat (T1>>c1) trait -> ???? T1 or nil (T2>>c1) trait (T2>>c2) trait -> ???? T2 or nil" self assert: (AUsingTrait2>>#foo) trait isNil. self assert: (AUsingTrait2>>#c3) trait = Trait2
we have
- The selector of a compiled method should be its name. An aliased method should have the name of its alias name. - The class of a compiled method is the class that contains it. A compiled method cannot be shared. - The origin of a compiledMethod is its defining class or trait.
- The reachHome of a compiled method is class or traits that you changed (and not override) when you want to change a method in the flat view.
It makes sense to me. What the reachHome is for? Alexandre
T1 c c1 T2 c c3 uses: T1 Class A foo uses: T2
testSelectorT11T2 "self debug: #testSelectorT11T2" "The selector of a compiled method should be its name. An aliased method should have the name of its alias name."
self assert: (AUsingTrait2>>#foo) selector = #foo. self assert: (Trait1>>#c) selector = #c. self assert: (Trait2>>#c) selector = #c. self assert: (AUsingTrait2>>#c) selector = #c. self assert: (AUsingTrait2>>#c3) selector = #c2. self assert: (BUsingTrait1>>#c) selector = #c.
testClassT11T2 "The class of a compiled method is the class that contains it. A compiled method cannot be shared."
self assert: (AUsingTrait2>>#foo) methodClass = AUsingTrait2. self assert: (AUsingTrait2>>#c) methodClass = AUsingTrait2. self assert: (AUsingTrait1>>#c3) methodClass = AUsingTrait2. self assert: (AUsingTrait2>>#c1) methodClass = AUsingTrait2. self assert: (BUsingTrait1>>#c) methodClass = BUsingTrait1.
self should: (Trait1>>#c1) methodClass = nil. "T1 or nil" self should: (Trait2>>#c2) methodClass = nil. "T2 or nil" self should: (Trait2>>#c1) methodClass = nil. "T2 or nil or T1"
testReachHome "self debug: #testReachHome" " The reachHome is the method that you changed (and not override) when you want to change a method in the flat view."
self assert: (AUsingTrait2>>#foo) reachHome = AUsingTrait2. self assert: (AUsingTrait2>>#c3) reachHome = Trait2. self assert: (AUsingTrait2>>#c1) reachHome = Trait1.
self assert: (AUsingTrait2>>#c) reachHome = Trait2.
self assert: (Trait11>>#c) reachHome = Trait11. self assert: (Trait2>>#c) reachHome = Trait2. self assert: (Trait2>>#c1) reachHome = Trait11.
self assert: (AUsingTrait1>>#c2) reachHome = AUsingTrait1.
testOrigin "self debug: #testClass" "The origin of a compiledMethod is its defining class or trait."
self assert: (AUsingTrait2>>#foo) origin = AUsingTrait2. self assert: (AUsingTrait2>>#c3) origin = Trait2. self assert: (AUsingTrait2>>#c1) origin = Trait11.
self assert: (AUsingTrait2>>#c) origin = Trait11.
self assert: (BUsingTrait1>>#c) origin = Trait1.
self assert: (Trait2>>#c3) origin = Trait2. self assert: (Trait11>>#c1) origin = Trait11. self assert: (Trait2>>#c1) origin = Trait11.
"since it introduced the alias it is its origin" self assert: (AUsingTrait1>>#c2) origin = AUsingTrait1.
testTraitT11T2
"it seems to me that we do not need trait: but we need origin and reachHome"
"(A>>foo) trait -> nil (A>>c3) trait -> T2 (A>>c) trait -> T2 (A>>c1) trait -> T2 ***** since it is flat (T1>>c1) trait -> ???? T1 or nil (T2>>c1) trait (T2>>c2) trait -> ???? T2 or nil"
self assert: (AUsingTrait2>>#foo) trait isNil.
self assert: (AUsingTrait2>>#c3) trait = Trait2
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
We change it with marcus Now we do not have reachHome. If you want to know load the MopTraits package in PharoTaskForces in the manifesto package you can get a nice UML diagram showing the config used for the tests :) Here are the test testClass "self debug: #testClass" "The class of a compiled method is the class that contains it. A compiled method is shared." "methodClass could call -> methodClassOrTrait" self assert: (Trait1>>#c) methodClass = Trait1. self assert: (Trait2>>#c) methodClass = Trait2. self assert: (C>>#c) methodClass = C. self assert: (C>>#c2) methodClass = C. self assert: (D>>#c) methodClass = D. self assert: (D>>#c2) methodClass = D. self assert: (D>>#c3) methodClass = D. self assert: (A>>#c2) methodClass = A. testOrigin "self debug: #testClass" "The origin of a compiledMethod is its defining class or trait." self assert: (C>>#c) origin = C. self assert: (A>>#c) origin = Trait3. self assert: (Trait3>>#c2) origin = Trait2. self assert: (A>>#c2) origin = Trait2. self assert: (B>>#c) origin = Trait1. self assert: (D>>#c3) origin = D. "this is a question because it could be " self assert: (D>>#c2) origin = Trait2. testSelector "self debug: #testSelector" "The selector of a compiled method should be its name. An aliased method should have the name of its alias name." self assert: (A>>#c) selector = #c. self assert: (C>>#c) selector = #c. self assert: (Trait3>>#c) selector = #c. self assert: (Trait3>>#c2) selector = #c2. self assert: (D>>#c3) selector = #c3. On Oct 10, 2008, at 9:10 AM, Alexandre Bergel wrote:
we have
- The selector of a compiled method should be its name. An aliased method should have the name of its alias name. - The class of a compiled method is the class that contains it. A compiled method cannot be shared. - The origin of a compiledMethod is its defining class or trait.
- The reachHome of a compiled method is class or traits that you changed (and not override) when you want to change a method in the flat view.
It makes sense to me. What the reachHome is for?
Alexandre
T1 c c1 T2 c c3 uses: T1 Class A foo uses: T2
testSelectorT11T2 "self debug: #testSelectorT11T2" "The selector of a compiled method should be its name. An aliased method should have the name of its alias name."
self assert: (AUsingTrait2>>#foo) selector = #foo. self assert: (Trait1>>#c) selector = #c. self assert: (Trait2>>#c) selector = #c. self assert: (AUsingTrait2>>#c) selector = #c. self assert: (AUsingTrait2>>#c3) selector = #c2. self assert: (BUsingTrait1>>#c) selector = #c.
testClassT11T2 "The class of a compiled method is the class that contains it. A compiled method cannot be shared."
self assert: (AUsingTrait2>>#foo) methodClass = AUsingTrait2. self assert: (AUsingTrait2>>#c) methodClass = AUsingTrait2. self assert: (AUsingTrait1>>#c3) methodClass = AUsingTrait2. self assert: (AUsingTrait2>>#c1) methodClass = AUsingTrait2. self assert: (BUsingTrait1>>#c) methodClass = BUsingTrait1.
self should: (Trait1>>#c1) methodClass = nil. "T1 or nil" self should: (Trait2>>#c2) methodClass = nil. "T2 or nil" self should: (Trait2>>#c1) methodClass = nil. "T2 or nil or T1"
testReachHome "self debug: #testReachHome" " The reachHome is the method that you changed (and not override) when you want to change a method in the flat view."
self assert: (AUsingTrait2>>#foo) reachHome = AUsingTrait2. self assert: (AUsingTrait2>>#c3) reachHome = Trait2. self assert: (AUsingTrait2>>#c1) reachHome = Trait1.
self assert: (AUsingTrait2>>#c) reachHome = Trait2.
self assert: (Trait11>>#c) reachHome = Trait11. self assert: (Trait2>>#c) reachHome = Trait2. self assert: (Trait2>>#c1) reachHome = Trait11.
self assert: (AUsingTrait1>>#c2) reachHome = AUsingTrait1.
testOrigin "self debug: #testClass" "The origin of a compiledMethod is its defining class or trait."
self assert: (AUsingTrait2>>#foo) origin = AUsingTrait2. self assert: (AUsingTrait2>>#c3) origin = Trait2. self assert: (AUsingTrait2>>#c1) origin = Trait11.
self assert: (AUsingTrait2>>#c) origin = Trait11.
self assert: (BUsingTrait1>>#c) origin = Trait1.
self assert: (Trait2>>#c3) origin = Trait2. self assert: (Trait11>>#c1) origin = Trait11. self assert: (Trait2>>#c1) origin = Trait11.
"since it introduced the alias it is its origin" self assert: (AUsingTrait1>>#c2) origin = AUsingTrait1.
testTraitT11T2
"it seems to me that we do not need trait: but we need origin and reachHome"
"(A>>foo) trait -> nil (A>>c3) trait -> T2 (A>>c) trait -> T2 (A>>c1) trait -> T2 ***** since it is flat (T1>>c1) trait -> ???? T1 or nil (T2>>c1) trait (T2>>c2) trait -> ???? T2 or nil"
self assert: (AUsingTrait2>>#foo) trait isNil.
self assert: (AUsingTrait2>>#c3) trait = Trait2
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
-- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Hi Stef, I had a look and I like it, so I'll try to make your tests pass ;). I don't agree with the following, though:
self assert: (D>>#c3) origin = D. "this is a question because it could be "
here I think it should be Trait2, not D. The alias c3->c2 does not redefine the method in the class; the method still originates in Trait2. So: (D>>#c3) origin = Trait2. Just like: (D>>#c2) origin = Trait2. Adrian
I had a look and I like it, so I'll try to make your tests pass ;).
I don't agree with the following, though:
self assert: (D>>#c3) origin = D. "this is a question because it could be "
here I think it should be Trait2, not D. The alias c3->c2 does not redefine the method in the class; the method still originates in Trait2.
Not really :) we discussed a lot with marcus and I think that I have a point :) the point is that since Compiled Method are copied so c3 is really different from c2 and c3 is not defined in Trait2 but this is realy because there is D that C3 exists. so tell me what you think. Stef
So: (D>>#c3) origin = Trait2. Just like: (D>>#c2) origin = Trait2.
Adrian
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
On 10.10.2008, at 14:30, Stéphane Ducasse wrote:
I had a look and I like it, so I'll try to make your tests pass ;).
I don't agree with the following, though:
self assert: (D>>#c3) origin = D. "this is a question because it could be "
here I think it should be Trait2, not D. The alias c3->c2 does not redefine the method in the class; the method still originates in Trait2.
Not really :) we discussed a lot with marcus and I think that I have a point :) the point is that since Compiled Method are copied
But even non-aliased methods are copied...
so c3 is really different from c2 and c3 is not defined in Trait2 but this is realy because there is D that C3 exists. so tell me what you think.
The problem with making the origin D is that then the relationship "all methods that have the origin class D are local methdos in class D" is not true anymore. I think it is more important to have this true for classes then for Traits. Marcus -- Marcus Denker -- denker@iam.unibe.ch http://www.iam.unibe.ch/~denker
On Oct 11, 2008, at 09:39 , Marcus Denker wrote:
On 10.10.2008, at 14:30, Stéphane Ducasse wrote:
I had a look and I like it, so I'll try to make your tests pass ;).
I don't agree with the following, though:
self assert: (D>>#c3) origin = D. "this is a question because it could be "
here I think it should be Trait2, not D. The alias c3->c2 does not redefine the method in the class; the method still originates in Trait2.
Not really :) we discussed a lot with and I think that I have a point :) the point is that since Compiled Method are copied
But even non-aliased methods are copied...
so c3 is really different from c2 and c3 is not defined in Trait2 but this is realy because there is D that C3 exists. so tell me what you think.
The problem with making the origin D is that then the relationship "all methods that have the origin class D are local methdos in class D" is not true anymore. marcus I think it is more important to have this true for classes then for Traits.
I agree with Marcus. The origin of a method for me means the behavior (trait or class) in which a method is originally defined. That is, if I want to modify the method without overriding it, this is the place to do it. Therefore, even though D introduces a new name for the method, the method still originates in Trait2. Adrian
OK for me.
the point is that since Compiled Method are copied
But even non-aliased methods are copied...
Indeed.
so c3 is really different from c2 and c3 is not defined in Trait2 but this is realy because there is D that C3 exists. so tell me what you think.
The problem with making the origin D is that then the relationship "all methods that have the origin class D are local methdos in class D" is not true anymore. marcus I think it is more important to have this true for classes then for Traits.
I agree with Marcus. The origin of a method for me means the behavior (trait or class) in which a method is originally defined. That is, if I want to modify the method without overriding it, this is the place to do it. Therefore, even though D introduces a new name for the method, the method still originates in Trait2.
Adrian _______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
participants (4)
-
Adrian Lienhard -
Alexandre Bergel -
Marcus Denker -
Stéphane Ducasse