[Pharo-users] Re: Can a class be not equal to itself?

2020-12-31 Thread Tudor Girba
Hi Konrad, Could it be that you have overridden = on the class side of your class? Otherwise, I do not see how this can happen. Cheers, Tudor > On Dec 31, 2020, at 12:19 PM, Konrad Hinsen > wrote: > > Hi everyone, > > > It's been a while since I have encountered mysterious behavior in Ph

[Pharo-users] Re: Can a class be not equal to itself?

2020-12-31 Thread Konrad Hinsen
On 31/12/2020 12:19, Konrad Hinsen wrote: It's been a while since I have encountered mysterious behavior in Pharo, but today it happened. I set up a dictionary with classes as keys, and got "Key not found" errors for keys that were definitely in my dictionary. A quick debugging session showed

[Pharo-users] Re: Can a class be not equal to itself?

2020-12-31 Thread Richard O'Keefe
#deepCopy is one of those things that is best avoided, because it violates the key principle of OOP that an object is in charge of its own data and behaviour. It can not so much break invariants as crush them and bury them in an unmarked grave, just like #shallowCopy. On Fri, 1 Jan 2021 at 03:25

[Pharo-users] Re: Can a class be not equal to itself?

2020-12-31 Thread Richard O'Keefe
What I said just now is true, but it doesn't tell the whole story. It turns out that Squeak, VisualWorks, GNU Smalltalk, and Pharo *deliberately* make aClass copy return a new class with the same superclass and methods (but no subclasses). Dolphin and VisualAge do not. So if you don't want to ma

[Pharo-users] Re: Can a class be not equal to itself?

2020-12-31 Thread Benoit St-Jean via Pharo-users
It never occurred to me that it would ever be the case! I've always thought classes were singleton and that SomeClass copy would always return the sole instance of that class! I wonder what are the implications of returning a copy, say, when you add an instVar to the "original" class ?  What

[Pharo-users] Re: Can a class be not equal to itself?

2021-01-01 Thread Konrad Hinsen
"Richard O'Keefe" writes: > #deepCopy is one of those things that is best avoided, > because it violates the key principle of OOP that an In the abstract, I agree. In practice, I don't see what else I could do for my use case. I have an object whose internal state is updated by incoming messages

[Pharo-users] Re: Can a class be not equal to itself?

2021-01-01 Thread Richard O'Keefe
Well, when you talk about "THE copying machinery" you have to be a bit more specific. There is no such thing as #deepCopy or #shallowCopy in the ANSI Smalltalk standard. Many Smalltalks have Object>>copy ^self shallowCopy postCopy and encourage you to override #postCopy. But nothing stops you d

[Pharo-users] Re: Can a class be not equal to itself?

2021-01-02 Thread ducasse
Hi Richard Indeed you are correct. We should continue to use and specialize postCopy. deepCopy and its friends such as veryDeepInnerInner …. do not smell good. Ideally I would like to remove all deepCopy and have a deepCopier that has a clear protocol and ask the objects. So may be at the end w

[Pharo-users] Re: Can a class be not equal to itself?

2021-01-02 Thread Konrad Hinsen
"Richard O'Keefe" writes: > Well, when you talk about "THE copying machinery" you have to be a bit more > specific. There is no such thing as #deepCopy or #shallowCopy in the ANSI > Smalltalk standard. Many Smalltalks have I am referring only to Pharo, which is the only Smalltalk I have ever u

[Pharo-users] Re: Can a class be not equal to itself?

2021-01-02 Thread ducasse
Hi konrad in fact I introduced postCopy/copy long time ago and did not get the force to clean the deepCopy and veryDeepInner mess. This is something that one day we will have to do. S > On 2 Jan 2021, at 12:17, Konrad Hinsen wrote: > > "Richard O'Keefe" writes: > >> Well, when you talk abo