implementation details questions

Florin Mateoc mateoc at orbonline.net
Sat Jun 13 03:35:54 UTC 1998


Please excuse me if some of these issues have already been discussed and
settled. If this is the case, could someone please post at least a reply
"by reference"  Thank you in advance.

1.
 Why is Object>>~~ implemented:
     self == anObject
          ifTrue: [^ false]
          ifFalse: [^ true]
while Object>>~=  is implemented:
     ^self = anObject == false

>From my measurements it looks like the second construct is slightly faster.
(Note: in VisualAge they use
     ^(self == anObject) not
and it is the fastest implementation (among the above three mentioned) for
VisualAge, which suggests that #not has more potential for optimization.
For Squeak this is the slowest implementation, #not not being optimized at
all (?))

2.
Object>>= could call directly the primitive 110, like Object>>==, instead
of calling Object>>==.
The same is true for Object>>hash, it could call directly primitive 75, like
Object>>identityHash.

3.
I looked at the implementations of #= and found that in most places there
is a parameter type check included. This is a more general issue (not
only for #=) and I think that these checks should be performed only when
necessary (and that implies checking outside the called method) - it should
be up to the developer to decide if this is the case. Besides, some methods
are not even  internally consistent, for example:
     Interval>>equal uses a weaker test and checks if the species of the
parameter is the same with self's species (Array), but then in the method
body it asks for the parameter's increment (and #increment is only
implemented by Interval).

4.
In Object>>deepCopy the message #deepCopy is further sent to the variables.
Shouldn't that message be #copy - this should be enough in most cases, it
is faster and it does not break for recursive structures - especially since
Squeak also provides a true deep copy (#veryDeepCopy) ?
The same Object>>deepCopy method also starts with the following (useless,
in my opinion) line:
     (class == Object) ifTrue: [^self].



That's all for now,

Florin





More information about the Squeak-dev mailing list