[squeak-dev] The Inbox: Environments-ul.43.mcz

Levente Uzonyi leves at elte.hu
Mon Dec 30 16:49:32 UTC 2013



On Mon, 30 Dec 2013, Colin Putney wrote:

> 
> 
> 
> On Sun, Dec 29, 2013 at 4:15 PM, <commits at source.squeak.org> wrote:
>
>       Item was changed:
>         ----- Method: Environment>>at:ifAbsentPut: (in category 'emulating') -----
>         at: aSymbol ifAbsentPut: aBlock
>       +
>       +       ^declarations
>       -       ^ declarations
>                       at: aSymbol
>       +               ifAbsent: [ self at: aSymbol put: aBlock value ]!
>       -               ifAbsentPut: aBlock!
> 
> 
> 
> Yup. We want to make use of the new become logic in #at:put: here too...
>  
>
>       Item was changed:
>         ----- Method: Environment>>at:put: (in category 'emulating') -----
>         at: aSymbol put: anObject
>       +
>       +       | binding newBinding |
>       +       newBinding := aSymbol => anObject.
>       +       binding := declarations associationAt: aSymbol ifAbsent: [ nil ].
>       +       binding ifNotNil: [
>       +               binding class == newBinding class
>       +                       ifTrue: [ binding value: anObject ]
>       +                       ifFalse: [ binding becomeForward: newBinding ].
>       +               ^anObject ].
>       +       binding := undeclared associationAt: aSymbol ifAbsent: [ nil ].
>       +       binding
>       +               ifNil: [ binding := newBinding ]
>       +               ifNotNil: [
>       +                       undeclared removeKey: aSymbol.
>       +                       binding class == newBinding class
>       +                               ifTrue: [ binding value: anObject ]
>       +                               ifFalse: [ binding becomeForward: newBinding ] ].
>       +       declarations add: binding.
>
>       +       references add: binding.
> 
> 
> I think the above line is problematic. It by by-passes all the import/export logic.

You're right, but this is somewhat intentional. Or do you want an imported 
class to shadow a class defined in your environment?

>  
>
>       +       exports bind: binding. "Do we really want this?"
> 
> 
> Yes.
>  
>
>       +       ^anObject
>
>       Item was changed:
>         ----- Method: Environment>>removeKey:ifAbsent: (in category 'emulating') -----
>         removeKey: key ifAbsent: aBlock
>       +
>       +       (declarations includesKey: key) ifFalse: [ ^aBlock value ].
>       +       references removeKey: key ifAbsent: [].
> 
> 
> Again, the above line by-passes all the import/export logic. 

Right.


Levente

> 
>  
> Colin
> 
> 
> 
>


More information about the Squeak-dev mailing list