[Q] Object size

Boris Gaertner Boris.Gaertner at gmx.net
Tue Feb 10 15:24:07 UTC 2004


In most Smalltalks, you can send #size to any object; for
fixed-sized objects, the answer is 0. In Squeak, the error
'not indexable' is signalled when #size is sent to a
fixed-sized object. (This is implemented in
Object>>size). To see this, you can try e.g.
   Model new size    and   Model new basicSize
The message #basicSize is always useable, it answers 0
when sent to fixed-sized objects.

In the Blue Book (edition from May 1983), we read on
page 100:
basicSize  Same as size. The method associated with this
        message, however, cannot be modified in any
        subclass.

size  Answer the receiver's number of indexed variables.
       This value is the same as the largest legal index.

The explanation given for 'size' is also given in the Squeak
method comments  for Object>>basicSize and Object>>size.

1. Question:
Should we modify Object>>size so that it will answer
0 when sent to fixed-sized objects? What problems are
to be feared when we do that?

2. Observation:
The sentence 'This value is the same as the largest legal
index' that we read in the comment for 'basicSize' is of
course not fully correct. Zero is not a legal index and the
comment should read: " When strictly positive, this
value is the same as the largest legal index, otherwise, the
receiver is not indexable."

You may wonder why I bother for that. Well, in old
HotDraw code, I found methods that assume that #size
can be sent to  nil  and will answer  0.  As a workaround,
I send #basicSize. 

Hoping for your good advice,
Boris



More information about the Squeak-dev mailing list