On 03 Sep 2014, at 17:29, Eliot Miranda <[email protected]> wrote:

> Hi Uko,
> 
> 
> On Wed, Sep 3, 2014 at 8:16 AM, Yuriy Tymchuk <[email protected]> wrote:
> one more question. How can you find out if method references a thing like 
> that?
> 
> Because if you do: #refersToLiteral: and pass a key from Undeclared you may 
> also match a symbol which is completely ok. Is there a way to check only for 
> variables?
> 
> You check for the binding.  e.g. self systemNavigation allCallsOn: 
> (Undeclared bindingOf: #Foo)
> 
> Are you sure refersToLiteral: answers true for a method that directly refers 
> to a binding but not directly to its key?  This sounds like a bug to me.

Hi

My bad. I didn’t know that literal in this case is a full binding i.e. 
association.
Thank you. Now I’ve got a bit smarter.

Uko 

> 
> 
> Uko
> 
> 
> On 03 Sep 2014, at 13:47, Marcus Denker <[email protected]> wrote:
> 
>> 
>> 
>> 
>> 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
> 
> 
> 
> 
> -- 
> best,
> Eliot

Reply via email to