<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">&lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>&gt;</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">&lt;<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>&gt;</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&gt;&gt;namespace: (in category &#39;create&#39;) -----<br>
- namespace: aDictionary<br>
-       ^ self namespace: aDictionary next: nil!<br>
<br>
Item was removed:<br>
- ----- Method: BindingPolicy class&gt;&gt;namespace:next: (in category &#39;create&#39;) -----<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&gt;&gt;namespace:policy: (in category &#39;create&#39;) -----<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&gt;&gt;namespace:policy:next: (in category &#39;create&#39;) -----<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&gt;&gt;null (in category &#39;create&#39;) -----<br>
- null<br>
-       ^ self namespace: IdentityDictionary new!<br>
<br>
Item was removed:<br>
- ----- Method: BindingPolicy&gt;&gt;forgetName: (in category &#39;private&#39;) -----<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&gt;&gt;initializeWithNamespace:policy:next: (in category &#39;initialize-release&#39;) -----<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: &#39;info declarations bindings undeclared policies observers&#39;<br>
-       instanceVariableNames: &#39;info imports exports declarations references public undeclared bindings policies observers&#39;<br>
        classVariableNames: &#39;Default Instances&#39;<br>
        poolDictionaries: &#39;&#39;<br>
        category: &#39;Environments-Core&#39;!<br>
<br>
  !Environment commentStamp: &#39;cmm 12/20/2013 14:10&#39; 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 &lt;EnvironmentInfo&gt;<br>
  Metadata about me and the code I contain.<br>
<br>
  imports &lt;Import&gt;<br>
  Rules for importing globals from other environments.<br>
<br>
  exports &lt;Export&gt;<br>
  Rules for exposing globals to other environments.<br>
<br>
  declarations &lt;IdentityDictionary&gt;<br>
  Bindings for globals that have been declared inside me.<br>
<br>
  references      &lt;IdentityDictionary&gt;<br>
  Bindings for globals that are used by methods compiled inside me.<br>
<br>
  public &lt;IdentityDictionary&gt;<br>
  Bindings for classes that have been declared inside me, and which satisfy the export rules contain in &#39;exports&#39;.<br>
<br>
  undeclared      &lt;Dictionary&gt;<br>
  Bindings for globals that are used by methods compiled inside me, but which aren&#39;t present in &#39;references&#39; and couldn&#39;t be found via the rules in &#39;imports&#39;.!<br>
<br></blockquote><div><br></div></div></div><div>&lt;rant&gt;<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&#39;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&#39;s a blind guess, that means that I change code without understanding the details, and that ain&#39;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&#39;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">&lt;/rant&gt;<br></div><div><div class="h5"><div class="gmail_quote"><div><br></div></div></div></div></div></div></blockquote><div><br></div><div>I&#39;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&#39;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&gt;&gt;migrate (in category &#39;initialize-release&#39;) -----<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 =&gt; 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&gt;&gt;public (in category &#39;accessing&#39;) -----<br>
- public<br>
-       ^ public!<br>
<br>
Item was removed:<br>
- ----- Method: Environment&gt;&gt;publicizeContents (in category &#39;private&#39;) -----<br>
- publicizeContents<br>
-       declarations associationsDo: [:binding | exports bind: binding].<br>
- !<br>
<br>
Item was removed:<br>
- ----- Method: Environment&gt;&gt;rebindUndeclared (in category &#39;private&#39;) -----<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: &#39;&#39;<br>
-       classVariableNames: &#39;&#39;<br>
-       poolDictionaries: &#39;&#39;<br>
-       category: &#39;Environments-Policies&#39;!<br>
<br>
Item was removed:<br>
- ----- Method: Export&gt;&gt;bind: (in category &#39;binding&#39;) -----<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&gt;&gt;bind:to: (in category &#39;binding&#39;) -----<br>
- bind: aSymbol to: anObject<br>
-       ^ self bind: aSymbol -&gt; anObject!<br>
<br>
Item was removed:<br>
- BindingPolicy subclass: #Import<br>
-       instanceVariableNames: &#39;&#39;<br>
-       classVariableNames: &#39;&#39;<br>
-       poolDictionaries: &#39;&#39;<br>
-       category: &#39;Environments-Policies&#39;!<br>
<br>
Item was removed:<br>
- ----- Method: Import&gt;&gt;bindingOf: (in category &#39;binding&#39;) -----<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&gt;&gt;valueOf: (in category &#39;binding&#39;) -----<br>
- valueOf: aSymbol<br>
-       ^ (self bindingOf: aSymbol) value!<br>
<br>
Item was added:<br>
+ (PackageInfo named: &#39;Environments&#39;) postscript: &#39;&quot;Recompile all methods to fix errant bindings&quot;<br>
+ Compiler recompileAll.<br>
+ &#39;!<br>
<br>
<br>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div>