<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2016-09-29 15:15 GMT+02:00 Jakob Reschke <span dir="ltr">&lt;<a href="mailto:jakob.reschke@student.hpi.de" target="_blank">jakob.reschke@student.hpi.de</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Environment&gt;&gt;associationAt: is part of the Smalltalk globals<br>
Dictionary compatibility interface, right? As a quick and dirty fix, I<br>
changed instances of Smalltalk at: xyz in Monticello code to<br>
CurrentEnvironment signal at: xyz, but #at: also only reads in the<br>
declarations, so myEnvironment at: #MCWriter or myEnvironment at:<br>
#Object returns nil by default. It would make more sense to perform a<br>
full lookup via #valueOf:ifAbsent: in #at: and its cousins, wouldn&#39;t<br>
it?<br>
<br>
Best,<br>
Jakob<br>
<span class=""><br></span></blockquote><div><br></div><div>I imagine that the question is about tools.<br></div><div>For now Smalltalk importSelf, so bindings and declarations do agree.<br></div><div>If an Environment does not importSelf, then some variables will be invisibles (unbounds). Do we still want to see them in some tool, or not?<br></div><div>What&#39;s going on if we play with Alias? Do we want to see the Alias in some browser? If not, then we&#39;d better stick with declarations.<br></div><div>There is no easy solution. A single facade for two dictionaries cannot fit all, so we need several different messages.<br></div><div>But it&#39;s much about what we want to do with those environments.<br></div><div><br> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
2016-09-29 7:33 GMT+02:00 H. Hirzel &lt;<a href="mailto:hannes.hirzel@gmail.com">hannes.hirzel@gmail.com</a>&gt;:<br>
&gt; On 9/28/16, Nicolas Cellier &lt;<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@<wbr>gmail.com</a>&gt; wrote:<br>
</span><span class="">&gt;&gt; Since we are at reviewing Environment, here is a small detail that bothers<br>
&gt;&gt; me. I already asked some months ago, but silence was the only response, so<br>
&gt;&gt; ping.<br>
&gt;&gt;<br>
&gt;&gt; Implementation of Environment is sometimes not obvious:<br>
&gt;&gt; - Environment&gt;&gt;associationAt: uses declarations inst.var..<br>
&gt;&gt; - Environment&gt;&gt;<wbr>associationOrUndeclaredAt: uses bindings inst.var.<br>
&gt;&gt; How can it be so different, the selector does not speak, does it?<br>
&gt;&gt;<br>
&gt;&gt; OK, there is a flag: #review in one of them, but that does not make code<br>
&gt;&gt; clearer, it&#39;s just a smell of over-complexity or ill-naming.<br>
&gt;&gt;<br>
&gt;&gt; Whatever the reason (self explaining code?) Colin does not comment<br>
&gt;&gt; class/methods, that&#39;s a fact.<br>
&gt;<br>
</span><span class="">&gt; Alternatively a description of the general ideas and the mechanism would help.<br>
&gt;<br>
&gt; After all Environments is just a clever combination of a few<br>
&gt; dictionaries  to look up class names? Isn&#39;t it?  ;-)<br>
&gt;<br>
&gt; However the fact that people did not move on much finalising the<br>
&gt; implementation of environments  since 2012 shows that it is hard to<br>
&gt; reverse-engineer the intentions from the (incomplete) code.<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</span><span class="">&gt;&gt; Chris made the effort of commenting Environment but then came this<br>
&gt;&gt; declarations/bindings split, and the comment did rapidly rot.<br>
&gt;&gt; We have here an un-healthy statu quo crying for change.<br>
&gt;&gt;<br>
&gt;&gt; So if we want to at least comment the class with the<br>
&gt;&gt; meaning/role/responsibility of inst vars, here is my understanding:<br>
&gt;&gt;<br>
&gt;&gt; environment bind: #Foo to: 0. just add to the declarations.<br>
&gt;&gt; (You see how names are not obvious: bind does not bind the new binding to<br>
&gt;&gt; bindings).<br>
&gt;<br>
</span><span class="">&gt; Environments<br>
&gt;<br>
&gt; bind: aSymbol to: anObject<br>
&gt;         | binding newBinding |<br>
&gt;         newBinding := aSymbol =&gt; anObject.<br>
&gt;<br>
&gt;         binding := declarations associationAt: aSymbol ifAbsent: [nil].<br>
&gt;         binding ifNotNil:<br>
&gt;                 [binding class == newBinding class<br>
&gt;                         ifTrue: [binding value: anObject]<br>
&gt;                         ifFalse: [binding becomeForward: newBinding].<br>
&gt;                 ^anObject].<br>
&gt;<br>
&gt;         binding := undeclared associationAt: aSymbol ifAbsent: [nil].<br>
&gt;         binding<br>
&gt;                 ifNil: [binding := newBinding]<br>
&gt;                 ifNotNil:<br>
&gt;                         [undeclared removeKey: aSymbol.<br>
&gt;                         binding class == newBinding class<br>
&gt;                                 ifTrue: [binding value: anObject]<br>
&gt;                                 ifFalse: [binding becomeForward: newBinding]].<br>
&gt;<br>
&gt;         declarations add: binding.<br>
&gt;         self binding: binding addedTo: self.<br>
&gt;         ^anObject<br>
&gt;<br>
&gt;<br>
&gt; Could you elaborate a bit please?<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</span><span class="">&gt;&gt; If the Environment importSelf, then the ClassBinding/Global also goes to<br>
&gt;&gt; bindings... (thru an observer pattern and the magic of naming policies)<br>
&gt;&gt;<br>
&gt;&gt; The bindings is what is used by the compiler, so what if an environment<br>
&gt;&gt; does not importSelf? It means that the variable it declares are not bound,<br>
&gt;&gt; so it is not reachable (kind of invisible class/Global).<br>
&gt;&gt;<br>
&gt;&gt; IOW, the bindings will contain all the imports, including self-imports.<br>
&gt;&gt; importSelf is generally what we want to do, unless weird cases of powerless<br>
&gt;&gt; environment for obfuscation or trustless sandboxing reason.<br>
&gt;&gt;<br>
&gt;&gt; Now, associationAt: does not speak for itself. It&#39;s too hard to decide if<br>
&gt;&gt; we&#39;re speaking of own declarations or bindings... Analyzing the usage is<br>
&gt;&gt; difficult. bindingAt: would be less ambiguous, so IMO we cannot fix without<br>
&gt;&gt; semantic shift.<br>
&gt;<br>
</span><span class="">&gt; This would need as well elaboration as well a separate thread.<br>
&gt;<br>
&gt;<br>
</span><span class="">&gt;&gt; The semantic will be carried by the senders (the Tools), and the tools by<br>
&gt;&gt; usage we want to make of Environment. So we first have to define that: what<br>
&gt;&gt; feature do we want to support? With which tool? That probably require yet<br>
&gt;&gt; another thread...<br>
&gt;<br>
</span>&gt; Yes<br>
&gt;<br>
&gt; --Hannes<br>
&gt;<br>
<br>
</blockquote></div><br></div></div>