sql.mawi at t-link.de
Wed Jun 16 09:56:34 UTC 2004
to prohibit a combinatorial explosion and answer your post in the same
thorough manner which is unique to you ;-) I grab the following as the
essence of what you said:
> A programmer cannot add something to a Smalltalk Set without getting
> a different *STATE* for that object, and the #= selector exists
> precisely to look at states. That's the point of the #== (same
> identity) -vs- #= (same state) distinction, after all.
My take was that an equality #= which is in fact an identity #== may
make sense, in that it supports what I called the programmer's
intuition about equality. Let's consider a Class "Database". The
programmer has a database and adds 1 record to an existing myriad
records. Would he intuitively think that his database is not the same
anymore? That it can't be found in a Set anymore? I guess many would
say it is the same, it just changed its contents. Otherwise I would
get every time I added a record a new database.
However, I understand that your position has its merits, too.
Here is a little snippet of code, which computes the number of classes
which do have state, but are not redefining #= to depend on that state.
For 3.6 it evaluates to 1136 out of 1338 classes. The majority of them
is ignoring your "platonic" equality. Is Squeak grossly constructed
falsely regarding equality, had it just been forgotten to do it right
or is this an unsolvable problem? Or does it simply show what the
average Smalltalk programmer intuitively thinks about equality? In
that case the current mixed view of equality (state or identity for
#=) in Smalltalk may fit to the language Smalltalk. And that means
that Squeak Sets very well could be implemented as they are in other
| classes |
classes := Smalltalk allClasses select: [ :cls |
(( cls allSuperclasses add: cls; yourself ) select: [ :c |
c includesSelector: #= ]) size = 1 ].
classes := classes select: [ :cls |
cls isVariable or: [
cls instVarNames isEmpty not or: [
( cls allSuperclasses detect: [ :c |
c instVarNames isEmpty not ] ifNone: ) notNil ]]].
classes size -> Smalltalk allClasses size
More information about the Squeak-dev