Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!oitnews.harvard.edu!yale!yale.edu!spool.mu.edu!howland.reston.ans.net!newsfeed.internetmci.com!news.kei.com!nntp.coast.net!torn!nott!cunews!tina.mrco.carleton.ca!knight
From: knight@mrco.carleton.ca (Alan Knight)
Subject: Re: OrderedCollection new:
X-Nntp-Posting-Host: tina.mrco.carleton.ca
Message-ID: <knight.820096315@tina.mrco.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Reply-To: knight@mrco.carleton.ca (Alan Knight)
Organization: The Object People
References: <4bgglt$bdp@ralph.vnet.net> <4bk6t3$jii@pcnet2.pcnet.net> <4bqnj1$snc@ralph.vnet.net>
Date: Wed, 27 Dec 1995 20:31:55 GMT
Lines: 33

In <4bqnj1$snc@ralph.vnet.net> tadpole@vnet.net writes:

>(OrderedCollection new: 123) size
>(OrderedCollection new: 123) basicSize

>Well, I did that, and, I got the same answer for both: 0!
>BTW, I am using IBM Smalltalk.  From previous replies, I gather that
>the phrase (OrderedCollection new: 123) might actually allocate space
>(while keeping the logical size 0), but, in IBM Smalltalk, this is apparently
>not the case.

IBM (and Digitalk's) implementation of OrderedCollection is different
in a subtle way from VisualWorks'. VisualWorks treats an
OrderedCollection as an indexable object and stores the contents
directly in it. The others have the Orderedcollection hold a reference
to an array (it's usually an array) that actually holds the contents.

This being true, I would expect basicSize , which answers the number
of indexable fields in the receiver, to always return zero for the
collection object.

The reason the implementations differ is subtle, and has to do with
the efficiency of become: and the presence/absence of an object table
or facsimile therof. You don't really want to know about that stuff
just yet.


-- 
 Alan Knight                | The Object People
 knight@acm.org             | Smalltalk and OO Training and Consulting
 alan@objectpeople.on.ca    | 509-885 Meadowlands Dr.
 +1 613 225 8812            | Ottawa, Canada, K2C 3N2

