[squeak-dev] The Trunk: Environments-cwp.43.mcz
Nicolas Cellier
nicolas.cellier.aka.nice at gmail.com
Mon May 26 21:19:45 UTC 2014
2014-01-03 21:58 GMT+01:00 <commits at source.squeak.org>:
> Colin Putney uploaded a new version of Environments to project The Trunk:
> http://source.squeak.org/trunk/Environments-cwp.43.mcz
>
> ==================== Summary ====================
>
> Name: Environments-cwp.43
> Author: cwp
> Time: 1 January 2014, 1:27:27.436 pm
> UUID: 3ccd33e2-0400-405d-b213-fc170cf0a3e6
> Ancestors: Environments-cwp.42
>
> Rewrite import/export to be eager, rather than lazy. (step 1 of 3)
>
> =============== Diff against Environments-cwp.42 ===============
>
> Item was removed:
> - ----- Method: BindingPolicy class>>namespace: (in category 'create')
> -----
> - namespace: aDictionary
> - ^ self namespace: aDictionary next: nil!
>
> Item was removed:
> - ----- Method: BindingPolicy class>>namespace:next: (in category
> 'create') -----
> - namespace: aDictionary next: anImport
> - ^ self
> - namespace: aDictionary
> - policy: AllNamePolicy new
> - next: anImport!
>
> Item was removed:
> - ----- Method: BindingPolicy class>>namespace:policy: (in category
> 'create') -----
> - namespace: aDictionary policy: aNamePolicy
> - ^ self
> - namespace: aDictionary
> - policy: aNamePolicy
> - next: nil!
>
> Item was removed:
> - ----- Method: BindingPolicy class>>namespace:policy:next: (in category
> 'create') -----
> - namespace: aDictionary policy: aNamePolicy next: anImport
> - ^ self new
> - initializeWithNamespace: aDictionary
> - policy: aNamePolicy
> - next: anImport!
>
> Item was removed:
> - ----- Method: BindingPolicy class>>null (in category 'create') -----
> - null
> - ^ self namespace: IdentityDictionary new!
>
> Item was removed:
> - ----- Method: BindingPolicy>>forgetName: (in category 'private') -----
> - forgetName: aSymbol
> - self name: aSymbol do: [:foreign |
> - namespace removeKey: foreign ifAbsent: [
> - next ifNotNil: [next forgetName: aSymbol]]].!
>
> Item was removed:
> - ----- Method: BindingPolicy>>initializeWithNamespace:policy:next: (in
> category 'initialize-release') -----
> - initializeWithNamespace: aDictionary policy: aNamePolicy next: anImport
> - namespace := aDictionary.
> - policy := aNamePolicy.
> - next := anImport!
>
> Item was changed:
> Object subclass: #Environment
> + instanceVariableNames: 'info declarations bindings undeclared
> policies observers'
> - instanceVariableNames: 'info imports exports declarations
> references public undeclared bindings policies observers'
> classVariableNames: 'Default Instances'
> poolDictionaries: ''
> category: 'Environments-Core'!
>
> !Environment commentStamp: 'cmm 12/20/2013 14:10' prior: 0!
> I am a context for compiling methods. I maintain the namespace of
> classes and global variables that are visible to the methods compiled
> within me.
>
> I have the following instance variables:
>
> info <EnvironmentInfo>
> Metadata about me and the code I contain.
>
> imports <Import>
> Rules for importing globals from other environments.
>
> exports <Export>
> Rules for exposing globals to other environments.
>
> declarations <IdentityDictionary>
> Bindings for globals that have been declared inside me.
>
> references <IdentityDictionary>
> Bindings for globals that are used by methods compiled inside me.
>
> public <IdentityDictionary>
> Bindings for classes that have been declared inside me, and which
> satisfy the export rules contain in 'exports'.
>
> undeclared <Dictionary>
> Bindings for globals that are used by methods compiled inside me, but
> which aren't present in 'references' and couldn't be found via the rules in
> 'imports'.!
>
>
<rant>
Hmm, the change of Environment definition would have deserved an update of
Environment comment...
Some senders of bindingOf: are currently not working (see
MCEnvironmentLoadTest), though they once did.
This is because bindingOf: uses bindings inst var which is left empty by
#testLoadIntoEnvironment.
This inst var is not documented and it's not obvious to guess its purpose.
It seems that declarations are filled, so I should probably use
declarationOf: instead of bindingOf:
But that's a blind guess, that means that I change code without
understanding the details, and that ain't good.
If I want to understand, I will have to open many browsers on senders
chains, tests, etc...
instead of reading a simple comment.
And if I want to review the senders of bindingOf:ifAbsent: / bindingOf:
then good luck...
Very few will be writing Environment code.
Many will read it.
My feeling as a reader is that the writers have lack of empathy with the
readers.
Maybe I'm dumb, but I like to be dumb.
Being smart costs too much energy, and in my experience, the smarter the
code, the merrier the missinterpretations (that is the bugs).
</rant>
Item was removed:
> - ----- Method: Environment>>migrate (in category 'initialize-release')
> -----
> - migrate
> - | newDeclarations source dest index policy |
> - bindings := IdentityDictionary new.
> - newDeclarations := IdentityDictionary new.
> - source := Array new: declarations size.
> - dest := Array new: declarations size.
> - index := 1.
> - declarations associationsDo:
> - [:ea || binding |
> - binding := ea key => ea value.
> - source at: index put: ea.
> - dest at: index put: binding.
> - newDeclarations add: binding.
> - bindings add: binding.
> - index := index + 1].
> - declarations := newDeclarations.
> - source elementsForwardIdentityTo: dest.
> -
> - policy := BindingPolicy
> - environment: self
> - policy: AllNamePolicy new
> - addSelector: #showBinding:
> - removeSelector: #hideBinding:.
> - policies := Array with: policy.
> -
> - observers := IdentitySet new..
> - !
>
> Item was removed:
> - ----- Method: Environment>>public (in category 'accessing') -----
> - public
> - ^ public!
>
> Item was removed:
> - ----- Method: Environment>>publicizeContents (in category 'private')
> -----
> - publicizeContents
> - declarations associationsDo: [:binding | exports bind: binding].
> - !
>
> Item was removed:
> - ----- Method: Environment>>rebindUndeclared (in category 'private') -----
> - rebindUndeclared
> - undeclared keys do:
> - [:name |
> - (imports valueOf: name) ifNotNil:
> - [:v |
> - references declare: name from: undeclared.
> - references at: name put: v]]!
>
> Item was removed:
> - BindingPolicy subclass: #Export
> - instanceVariableNames: ''
> - classVariableNames: ''
> - poolDictionaries: ''
> - category: 'Environments-Policies'!
>
> Item was removed:
> - ----- Method: Export>>bind: (in category 'binding') -----
> - bind: aBinding
> -
> - self name: aBinding key do:
> - [:foreign | ^ namespace add: (aBinding asBinding:
> foreign)].
> - ^ next ifNotNil: [next bind: aBinding]!
>
> Item was removed:
> - ----- Method: Export>>bind:to: (in category 'binding') -----
> - bind: aSymbol to: anObject
> - ^ self bind: aSymbol -> anObject!
>
> Item was removed:
> - BindingPolicy subclass: #Import
> - instanceVariableNames: ''
> - classVariableNames: ''
> - poolDictionaries: ''
> - category: 'Environments-Policies'!
>
> Item was removed:
> - ----- Method: Import>>bindingOf: (in category 'binding') -----
> - bindingOf: aSymbol
> - self name: aSymbol do:
> - [:foreign |
> - ^ namespace
> - associationAt: foreign
> - ifAbsent: [next ifNotNil: [next bindingOf:
> aSymbol]]].
> - ^ next ifNotNil: [next bindingOf: aSymbol]!
>
> Item was removed:
> - ----- Method: Import>>valueOf: (in category 'binding') -----
> - valueOf: aSymbol
> - ^ (self bindingOf: aSymbol) value!
>
> Item was added:
> + (PackageInfo named: 'Environments') postscript: '"Recompile all methods
> to fix errant bindings"
> + Compiler recompileAll.
> + '!
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140526/1b54bd0d/attachment.htm
More information about the Squeak-dev
mailing list
|