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