Re: Semantics of Set>>new in Squeak 3.9 -- To initialize or not to

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Semantics of Set>>new in Squeak 3.9 -- To initialize or not to

Wolfgang Helbig
Hi List,

Nicolas observed:
>So there are two possible implementations of new:
>The one in Behavior for classes really declared as variableSubclass
> (self basicNew: n) initialize
>The one in other classes, faking an indexable behaviour, but implementing this
>behaviour indirectly by the mean of an indexable instance variable
> (self basicNew) initialize: n
Why do we need two implementations if one suffice?
If I am not mistaken, classes that are defined as variableSubclass in ST-80 are
defined as subclass in Squeak. Is this a tendency of modern Smalltalk systems.
And if so, why?

Regards,
Wolfgang
--
Weniger, aber besser.


Reply | Threaded
Open this post in threaded view
|

Re: Semantics of Set>>new in Squeak 3.9 -- To initialize or not to

Andreas.Raab
Wolfgang Helbig wrote:
> If I am not mistaken, classes that are defined as variableSubclass in ST-80 are
> defined as subclass in Squeak. Is this a tendency of modern Smalltalk systems.
> And if so, why?

Because ST-80 used an object table which makes #become: a very fast
operation and many newer (not necessarily more "modern") variants use
direct pointer models which makes #become: a very slow operation. If
#beome: is fast, using indexed subclasses is more efficient (less space
overhead, potentially faster because of the lack of an extra
indirection) whereas if #become: is slow you really want to store the
array data in an instance variable instead (so you can copy the array if
it needs to grow/shrink).

Cheers,
   - Andreas