Hi, I want to determine if a trait composition is different than other, for example: newClass traitComposition = oldClass traitComposition But I didn't find an implementation. I imagine the simple implementation that checks that all of its components are equal recursively. The components are instances of either Trait, TraitAlias or TraitExclusion, and it should be simple to define = on each of them. Do experts on traits agree? I can open an issue and propose a slice. This arose when looking into issue 12157, where the problem is that ClassModifiedClassDefinition is always announced because the trait composition *may* have changed. This way, ClassModifiedClassDefinition is announced even when it was a class creation. We could also workaround the lack of trait composition equality by comparing their 'asString's... Bests, MartÃn
On Tue, Jan 21, 2014 at 5:29 PM, Martin Dias <tinchodias@gmail.com> wrote:
Do experts on traits agree? I can open an issue and propose a slice.
you have to pay attention that A + B + C = B + A + C = C + A + B. -- Damien Cassou http://damiencassou.seasidehosting.st "Success is the ability to go from one failure to another without losing enthusiasm." Winston Churchill
On Tue, Jan 21, 2014 at 6:02 PM, Damien Cassou <damien.cassou@gmail.com>wrote:
On Tue, Jan 21, 2014 at 5:29 PM, Martin Dias <tinchodias@gmail.com> wrote:
Do experts on traits agree? I can open an issue and propose a slice.
you have to pay attention that A + B + C = B + A + C = C + A + B.
ok, I will propose a slice
should (T1 @ {#a -> #b} @ {#x -> #y}) = (T1 @ {#x -> #y} @ {#a -> #b}) ? On Tue, Jan 21, 2014 at 6:39 PM, Martin Dias <tinchodias@gmail.com> wrote:
On Tue, Jan 21, 2014 at 6:02 PM, Damien Cassou <damien.cassou@gmail.com>wrote:
On Tue, Jan 21, 2014 at 5:29 PM, Martin Dias <tinchodias@gmail.com> wrote:
Do experts on traits agree? I can open an issue and propose a slice.
you have to pay attention that A + B + C = B + A + C = C + A + B.
ok, I will propose a slice
On 22 janv. 2014, at 10:13, Martin Dias <tinchodias@gmail.com> wrote:
On Wed, Jan 22, 2014 at 10:05 AM, Martin Dias <tinchodias@gmail.com> wrote: should
(T1 @ {#a -> #b} @ {#x -> #y}) = (T1 @ {#x -> #y} @ {#a -> #b})
?
two more:
(T1 - {#a. #b}) = (T1 - {#b. #a})
(T1 - {#a} - {#b}) = (T1 - {#b} - {#a})
I would say yes for each case.
You should be really careful when doing this. The fact that two compositions (T1 @ {#a -> #b} @ {#x -> #y}) and (T1 @ {#x -> #y} @ {#a -> #b}) are semantically the same does not mean that the way in which they are expressed in class/trait definition is not important of some importance for programmer. That's pretty much like indentation - code which is properly indented with nice long variable names is could be semantically equivalent to the code which is total mess in a single line but to programmers the difference is huge - at least for me. If you really need semantic/structural equivalence, you'd better flatten protocols of both compositions and compare these. This would handle correctly even this case: TX = (T1 + T3) (T1 + T2 + T3) <==> (T2 + TX) Best, Jan On 22/01/14 09:33, Camille Teruel wrote:
On 22 janv. 2014, at 10:13, Martin Dias <tinchodias@gmail.com <mailto:tinchodias@gmail.com>> wrote:
On Wed, Jan 22, 2014 at 10:05 AM, Martin Dias <tinchodias@gmail.com <mailto:tinchodias@gmail.com>> wrote:
should
(T1 @ {#a -> #b} @ {#x -> #y}) = (T1 @ {#x -> #y} @ {#a -> #b})
?
two more:
(T1 - {#a. #b}) = (T1 - {#b. #a})
(T1 - {#a} - {#b}) = (T1 - {#b} - {#a})
I would say yes for each case.
It looks like you're asking if substitution (@) is commutative. In the general case it's not: T1 @ {#x -> #y} @ {#y -> #z} == T1 but T1 @ {#y -> #z} @ {#x -> #y} is not. I think Jan's suggestion of flattening the traits and then comparing them for semantic/structural equivalence is the right way to avoid going crazy! frank On 22 January 2014 09:05, Martin Dias <tinchodias@gmail.com> wrote:
should
(T1 @ {#a -> #b} @ {#x -> #y}) = (T1 @ {#x -> #y} @ {#a -> #b})
?
On Tue, Jan 21, 2014 at 6:39 PM, Martin Dias <tinchodias@gmail.com> wrote:
On Tue, Jan 21, 2014 at 6:02 PM, Damien Cassou <damien.cassou@gmail.com> wrote:
On Tue, Jan 21, 2014 at 5:29 PM, Martin Dias <tinchodias@gmail.com> wrote:
Do experts on traits agree? I can open an issue and propose a slice.
you have to pay attention that A + B + C = B + A + C = C + A + B.
ok, I will propose a slice
Good points. Thanks, they made my rethink. In my case, I need to detect if a class definition has changed, to announce it. The order looks like important here. I agree with Jan that if somebody reorders the trait composition of a class definition, this should be considered as a change. So, even the simple A + B = B + A should be false. If you want, we can implement this equality with other selector than #=, but I think this is the right criteria. MartÃn
Please, can you review? https://pharo.fogbugz.com/f/cases/12689/Implement-equality-in-TraitCompositi... thanks, MartÃn On Wed, Jan 22, 2014 at 11:23 AM, Martin Dias <tinchodias@gmail.com> wrote:
Good points. Thanks, they made my rethink.
In my case, I need to detect if a class definition has changed, to announce it. The order looks like important here. I agree with Jan that if somebody reorders the trait composition of a class definition, this should be considered as a change. So, even the simple A + B = B + A should be false.
If you want, we can implement this equality with other selector than #=, but I think this is the right criteria.
MartÃn
This is my impression too but it is late. Especially since traits are designed to avoid to take care about structure of the trait ânestingâ. We do not care that a method come from T1 or T1.T2 Stef
It looks like you're asking if substitution (@) is commutative. In the general case it's not:
T1 @ {#x -> #y} @ {#y -> #z} == T1
but
T1 @ {#y -> #z} @ {#x -> #y}
is not.
I think Jan's suggestion of flattening the traits and then comparing them for semantic/structural equivalence is the right way to avoid going crazy!
frank
On 22 January 2014 09:05, Martin Dias <tinchodias@gmail.com> wrote:
should
(T1 @ {#a -> #b} @ {#x -> #y}) = (T1 @ {#x -> #y} @ {#a -> #b})
?
On Tue, Jan 21, 2014 at 6:39 PM, Martin Dias <tinchodias@gmail.com> wrote:
On Tue, Jan 21, 2014 at 6:02 PM, Damien Cassou <damien.cassou@gmail.com> wrote:
On Tue, Jan 21, 2014 at 5:29 PM, Martin Dias <tinchodias@gmail.com> wrote:
Do experts on traits agree? I can open an issue and propose a slice.
you have to pay attention that A + B + C = B + A + C = C + A + B.
ok, I will propose a slice
participants (6)
-
Camille Teruel -
Damien Cassou -
Frank Shearar -
Jan Vrany -
Martin Dias -
Pharo4Stef