[squeak-dev] Global variable lookup

Bert Freudenberg bert at freudenbergs.de
Fri Jan 11 19:22:56 UTC 2013


On 11.01.2013, at 11:19, Eliot Miranda <eliot.miranda at gmail.com> wrote:

> On Fri, Jan 11, 2013 at 11:05 AM, Igor Stasenko <siguctua at gmail.com> wrote:
>> FYI, this is a code from Pharo, which we are did _right_ (of course
>> from Pharo perspective ;)
>> 
> +1.  local variable definitions override explicitly imported variable definitions inherited variable definitions override "global" variable definitions.

Yep. Thanks Igor, that looks more reasonable.

>> But does the system automatically recompile importers of shared pools when bindings are added or removed from shared pools?  At least Squeak does not.  And this is an issue in the context of loading Monticello packages.  With the VMMaker I refactored a lot of globals into shared p[ools when I decomposed ObjectMemory from the Interpreter hierarchy and added the Cogit hierarchy.  I would have to manually recompile to get the references right on e.g. moving a variable from being a class variable of ObjectMemory into some shared pool, or on moving the variable from one shared pool to another.

Let's fix it.

- Bert -

>>  
>> 
>> Class>>bindingOf: varName
>>         "Answer the binding of some variable resolved in the scope of the
>> receiver, or nil
>>         if variable with such name is not defined"
>> 
>>         "The lookup recurses up to superclasses looking inside their class
>> and shared pools,
>>         but not the environment, since two classes, even if they have
>> ancestry relationship,
>>         could use different environments.
>>         That's why we doing an environment lookup only as a last step of symbol lookup
>>         and taking only the environment of receiver only, not any of it's
>> superclass(es) "
>> 
>>         | aSymbol binding |
>>         aSymbol := varName asSymbol.
>> 
>>         ^ (self innerBindingOf: aSymbol) ifNil: [
>>                  self environment bindingOf: aSymbol
>>         ]
>> 
>> 
>> Class>>innerBindingOf: aSymbol
>>         "Answer the binding of some variable resolved in the scope of the
>> receiver, or one of its superclass
>>         but do not look up binding in receiver's environment.
>>         Use #bindingOf: for looking up the variable binding in a full scope,
>> including receiver's environment"
>> 
>>         | binding |
>> 
>>         "First look in classVar dictionary."
>>         binding := self classPool bindingOf: aSymbol.
>>         binding ifNotNil: [^binding].
>> 
>>         "Next look in shared pools."
>>         self sharedPools do: [:pool |
>>                 | aBinding |
>>                 aBinding := pool bindingOf: aSymbol.
>>                 aBinding ifNotNil: [^aBinding ].
>>         ].
>> 
>>         superclass ifNotNil: [
>>                 ^ superclass innerBindingOf: aSymbol.
>>         ].
>>         ^ nil
>> 
>> 
>> On 11 January 2013 19:28, Bert Freudenberg <bert at freudenbergs.de> wrote:
>> > bindingOf:environment:
>> 
> 
> 
> --
> Best regards,
> Igor Stasenko.
> 
> 
> 
> 
> -- 
> best,
> Eliot
> 




More information about the Squeak-dev mailing list