On Wed, Sep 3, 2014 at 11:24 AM, Yuriy Tymchuk <[email protected]> wrote:

> Hi, can someone explain me how Undeclared dictionary works?
>
>
So imagine you want to load code where a variable is not defined (e.g. due
to loading old code,
or because it references a variable that will only be loaded in a second
step).

In interactive mode, the compiler tells you. But in non-interactive mode
(file in, mc load),
it just loads the wrong code and for every undeclared variable, it adds an
entry in the
Undeclared dictionary.
(the bytecode to read and write is the same as used for Globals and Class
variables:
pushLiteralVariable, which means "push the value of the association", the
store bytecode
for assignment therefore is "store in the value of that association".

So if you actually run code that has Undeclared, it will work: it will be
nil by default,
but when you assign it will store into the Undeclared dictionary.

When you add a new Global to the SystemDictionary, it will check Undeclared
and
move the value over. Same for Class vars.
(this means that loading a class will automatically fix all Undeclared
references to it)



> Because as I look at it, all the values are nil. Is it possible for them
> to be not nil?
>
> yes.


> Maybe we should have a “global variable comments” for this situations :)
>
>
Ideed.

--
Marcus Denker  --  [email protected]
http://www.marcusdenker.de

Reply via email to