Tips and tricks?

Adrian Lienhard adi at netstyle.ch
Wed Mar 10 19:55:20 UTC 2004


George Bosworth wrote:
[..]
> Add a new instance variable to Object--ideally
> this should or could be made to work, but in practice often becomes
> impractical.  I don't think any Smalltalk system in that era (late
> 80s-early 90s) could actually do this (there is a deep hard problem
> with changing the shape of objects whose layout is know to the
> vm-implementation itself--but these are quite few in number).

Exactly. The problem is that the vm accesses the IVs 'superclass',
'methodDict' and
'format' by indexes. (e.g., see Interpreter class>>initializeClassIndices
and Interpreter>>superclassOf: classPointer or the Bluebook). The ordering
of IVs is "allIVs = superclass allIVs , class allIVs" (IVs of the
superclasses come first). That means, when you add an IV to a superclass of
Behavior, the indexes of the three original IVs of Behavior should be
increased by one to make it work (so, you have to modify the vm).

> But their failure modes were quite interesting: ranging from notifiers
> saying sorry can't do that, to infinite looping, to recursive does
> not understand, to process and or machine lockups and crashes.

In Squeak, the classbuilder prevents you from redefining Behavior. But if
you do anyway and add instance variables to a superclass of Behavior the vm
will crash (from my experience with implementing Traits)...

Regards,
Adrian


>
> -----Original Message-----
> From: squeak-dev-bounces at lists.squeakfoundation.org
> [mailto:squeak-dev-bounces at lists.squeakfoundation.org] On Behalf Of
> ducasse
> Sent: Wednesday, March 10, 2004 9:27 AM
> To: The general-purpose Squeak developers list
> Subject: Re: Tips and tricks?
>
> romain
> no reread my email. the problem is that reference to instance
> variables are converted to offset in the bytecode. So this is not
> sure that if you allow to add a method that the right offset will be
> found especially because you do not want
> to recompile all the code. (may be there is a trick or heuristic
> sorting the
> iv but I did not go deep enough into it)
>
> Stef
>
> On 10 mars 04, at 16:38, Romain Robbes wrote:
>
>> Hi stef,
>>
>> Would the AddInstanceVariableRefactoring solve your
>> problem ?
>> Just wondering ...

_____________________
Adrian Lienhard
www.adrian-lienhard.ch
www.netstyle.ch




More information about the Squeak-dev mailing list