[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Behaviour>>addInstVarName: causes error

From: Mike Anderson
Subject: [Help-smalltalk] Behaviour>>addInstVarName: causes error
Date: 29 Apr 2003 09:32:38 +0100

Causes IndexOutOfRangeException under some circumstances (I haven't
thought it all the way through, but in the cases when it doesn't, I
suspect something unpleasant may be occurring).

(I'd post fuller call stacks, but there isn't an easy way to cut&paste
them as yet :) ).

The exception is raised by
  result replaceFrom: start to: start + repSize - 1 with:

There's nothing wrong with that, except that (start + repSize - 1) >
(result size).

Basically this is because addInstVarName: updates instanceVariables and
instanceSpec before calling
Behavour>>updateInstanceVars:variable:words:pointers:. As a result, the

  endOfInstanceVars :=  self instSize.

Gives the new, updated value, whereas, when updating the subclasses, the
code rather assumes that it is the old value:

  iv := sc allInstVarNames copyReplaceFrom: startOfInstanceVars to:
endOfInstanceVars with: newInstanceVars

I hope that's easy enough to follow. There are various ways to reproduce
it, but:

BLOX.BWidget addInstVarName: 'tag'

Will certainly do it for you.

Now, addInstVarName: and removeInstVarName: actually update
instanceVariables themselves, but Metaclass>>instanceVariableNames: does
not. It seems to me that the solution is for addInstVarName: and
removeInstVarName: to also delegate the update, however, my simplistic
efforts to make this change don't work very well (possibly I need to
test them with a change that doesn't destroy the browser if it doesn't
work :) ). 

Incidentally, in removeInstVarName:, surely the subclasses should only
be recompiled /after/ the variables have been updated?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]