[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 happens to the reshaping 
of the instances created by the copy?


On 2020-12-31 20:25, Richard O'Keefe wrote:

Squeak, VisualWorks,
GNU Smalltalk, and Pharo *deliberately* make
aClass copy


--
-
Benoît St-Jean
Yahoo! Messenger: bstjean
Twitter: @BenLeChialeux
Pinterest: benoitstjean
Instagram: Chef_Benito
IRC: lamneth
GitHub: bstjean
Blogue: endormitoire.wordpress.com
"A standpoint is an intellectual horizon of radius zero".  (A. Einstein)



[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 make copies of classes,
you must avoid ALL of #deepCopy, #shallowCopy, AND #copy.


On Fri, 1 Jan 2021 at 13:59, Richard O'Keefe  wrote:

> #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, Konrad Hinsen 
> wrote:
>
>> 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 the underlying issue:
>> > I had two references to a class which look the same when inspected,
>> > but turn out to be not identical (==) and thus not equal (=). How can
>> > this happen?
>>
>>
>> Update, after a few more debugging sessions: my dictionary is the result
>> of a deepCopy operation, meaning the class has been copied. And the copy
>> of a class is indeed a distinct but otherwise indistinguishable class.
>> 'Object copy = Object' is 'false'.
>>
>>
>> Konrad.
>>
>


[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, Konrad Hinsen 
wrote:

> 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 the underlying issue:
> > I had two references to a class which look the same when inspected,
> > but turn out to be not identical (==) and thus not equal (=). How can
> > this happen?
>
>
> Update, after a few more debugging sessions: my dictionary is the result
> of a deepCopy operation, meaning the class has been copied. And the copy
> of a class is indeed a distinct but otherwise indistinguishable class.
> 'Object copy = Object' is 'false'.
>
>
> Konrad.
>


[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 the underlying issue: 
I had two references to a class which look the same when inspected, 
but turn out to be not identical (==) and thus not equal (=). How can 
this happen?



Update, after a few more debugging sessions: my dictionary is the result 
of a deepCopy operation, meaning the class has been copied. And the copy 
of a class is indeed a distinct but otherwise indistinguishable class. 
'Object copy = Object' is 'false'.



Konrad.


[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 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 the underlying issue: I had two references to a 
> class which look the same when inspected, but turn out to be not identical 
> (==) and thus not equal (=). How can this happen?
> 
> 
> Konrad.

--
feenk.com

"It's not how it is, it is how we see it."


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

2020-12-31 Thread Konrad Hinsen

Hi everyone,


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 the underlying issue: I had 
two references to a class which look the same when inspected, but turn 
out to be not identical (==) and thus not equal (=). How can this happen?



Konrad.