[squeak-dev] Global variable lookup

Igor Stasenko siguctua at gmail.com
Fri Jan 11 22:02:42 UTC 2013


On 11 January 2013 20: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.
>
> But does the system automatically recompile importers of shared pools when
> bindings are added or removed from shared pools?  At least Squeak does not.

i did not checked, but i suspecting Pharo is on par with Squeak on this :)
You are right, changing pool should trigger recompilation of
all dependent classes.

> 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.
>
>>
>>
>> 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
>
>
>



-- 
Best regards,
Igor Stasenko.


More information about the Squeak-dev mailing list