<br><br><div class="gmail_quote">On Thu, Jan 21, 2010 at 4:33 AM, Juan Vuletich <span dir="ltr">&lt;<a href="mailto:juan@jvuletich.org">juan@jvuletich.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Thanks, Nicolas. You&#39;re right. I did include the preference in Cuis. By default it is set not to allow assignment to block args. I recompiled the whole system this way, removing any block arg assgnment left. I see no reason to allow them, but the preference is there if someone needs it.<br>
</blockquote><div><br></div><div>Agreed.  I put in the preference for cases such as loading packages containing assignments to block temps.  Without the preference it is additional work to load the package (unpacking the .mcz by hand and editing the source file).  Once the package is loaded one can hunt down and rewrite those assignments.  But how does one find them other than by resetting the preference and recompiling the package?  And how does one find block argument assignments lurking in unpackaged code save recompiling the entire system?  One abuses MessageNotUnderstood, that&#39;s how.  Here&#39;s a hack implementation of SystemNavigation allBlockArgumentAssignations.  It has just found 35 such abominations in my development image (shock, horror).  Change set attached.  Code in all its syntax coloured glory below.  Enjoy.</div>
<div><br></div><div><span class="Apple-style-span" style="font-family: Times; font-size: medium; "><font color="#000000"><i>SystemNavigation methods for query</i></font><font color="#000000"> <br>allBlockArgumentAssignations <br>
        </font><font color="#008080">&quot;Answer all methods containing an assignment to a block argument.&quot;</font><font color="#000000"> <br>        </font><font color="#008080">&quot;SystemNavigation default <br>                        browseMessageList: SystemNavigation default allBlockArgumentAssignations asSortedCollection <br>
                        name: &#39;Assignments to block arguments&#39;&quot;</font><font color="#000000"> <br>        </font><font color="#800000">^self</font><font color="#000000"> </font><font color="#000080">allMethodsSelect:</font><font color="#000000"> <br>
                        [:</font><font color="#000080">m</font><font color="#808080">|</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> </font><font color="#808080">d</font><font color="#000000"> </font><font color="#808080">assignsToBlockArg</font><font color="#000000"> </font><font color="#808080">scanner</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> <br>
                        </font><font color="#808080">assignsToBlockArg</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#800000">false</font><font color="#000000">. <br>                        </font><font color="#008000">(</font><font color="#808080">d</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#000080">m</font><font color="#000000"> </font><font color="#000080">blockpcsToBlockExtents</font><font color="#008000">)</font><font color="#000000"> </font><font color="#000080">size</font><font color="#000000"> </font><font color="#000080">&gt;=</font><font color="#000000"> </font><font color="#800000">2</font><font color="#000000"> </font><font color="#000080">ifTrue:</font><font color="#000000"> <br>
                                        </font><font color="#008000">[</font><font color="#808080">scanner</font><font color="#000000"> </font><b>:=</b><font color="#000000"> InstructionStream </font><font color="#000080">on:</font><font color="#000000"> </font><font color="#000080">m</font><font color="#000000">. <br>
                                        </font><font color="#808080">d</font><font color="#000000"> </font><font color="#000080">keysDo:</font><font color="#000000"> <br>                                                        </font><font color="#800080">[</font><font color="#000000">:</font><font color="#000080">interval</font><font color="#808080">|</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> </font><font color="#808080">nArgs</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> <br>
                                                        </font><font color="#800000">(</font><font color="#000080">interval</font><font color="#000000"> </font><font color="#000080">first</font><font color="#000000"> </font><font color="#000080">~=</font><font color="#000000"> </font><font color="#000080">m</font><font color="#000000"> </font><font color="#000080">initialPC</font><font color="#000000"> <br>
                                                         </font><font color="#000080">and:</font><font color="#000000"> </font><font color="#00EB00">[</font><font color="#EB8D00">(</font><font color="#808080">nArgs</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#000080">m</font><font color="#000000"> </font><font color="#000080">argumentCountForBlockAtPC:</font><font color="#000000"> </font><font color="#000080">interval</font><font color="#000000"> </font><font color="#000080">first</font><font color="#EB8D00">)</font><font color="#000000"> </font><font color="#000080">&gt;</font><font color="#000000"> </font><font color="#800000">0</font><font color="#00EB00">]</font><font color="#800000">)</font><font color="#000000"> </font><font color="#000080">ifTrue:</font><font color="#000000"> <br>
                                                                        </font><font color="#800000">[</font><font color="#808080">scanner</font><font color="#000000"> </font><font color="#000080">pc:</font><font color="#000000"> </font><font color="#000080">interval</font><font color="#000000"> </font><font color="#000080">first</font><font color="#000000">. <br>
                                                                        </font><font color="#00EB00">[</font><font color="#808080">scanner</font><font color="#000000"> </font><font color="#000080">pc</font><font color="#000000"> </font><font color="#000080">&lt;=</font><font color="#000000"> </font><font color="#000080">interval</font><font color="#000000"> </font><font color="#000080">last</font><font color="#00EB00">]</font><font color="#000000"> </font><font color="#000080">whileTrue:</font><font color="#000000"> <br>
                                                                                        </font><font color="#00EB00">[</font><font color="#EB8D00">[</font><font color="#808080">scanner</font><font color="#000000"> </font><font color="#000080">interpretNextInstructionFor:</font><font color="#000000"> </font><font color="#800000">nil</font><font color="#EB8D00">]</font><font color="#000000"> <br>
                                                                                                        </font><font color="#000080">on:</font><font color="#000000"> MessageNotUnderstood <br>                                                                                                        </font><font color="#000080">do:</font><font color="#000000"> </font><font color="#EB8D00">[</font><font color="#000000">:</font><font color="#000080">ex</font><font color="#808080">|</font><font color="#000000"> <br>
                                                                                                                        </font><font color="#EB00EB">(</font><font color="#0000FF">(</font><font color="#000000">#(</font><font color="#000080">popIntoTemporaryVariable:</font><font color="#000000"> <br>
                                                                                                                                        </font><font color="#000080">storeIntoTemporaryVariable:</font><font color="#000000">) </font><font color="#000080">includes:</font><font color="#000000"> </font><font color="#000080">ex</font><font color="#000000"> </font><font color="#000080">message</font><font color="#000000"> </font><font color="#000080">selector</font><font color="#0000FF">)</font><font color="#000000"> <br>
                                                                                                                        </font><font color="#000080">and:</font><font color="#000000"> </font><font color="#0000FF">[</font><font color="#000080">ex</font><font color="#000000"> </font><font color="#000080">message</font><font color="#000000"> </font><font color="#000080">arguments</font><font color="#000000"> </font><font color="#000080">first</font><font color="#000000"> </font><font color="#000080">+</font><font color="#000000"> </font><font color="#800000">1</font><font color="#000000"> </font><font color="#000080">&lt;=</font><font color="#000000"> </font><font color="#808080">nArgs</font><font color="#0000FF">]</font><font color="#EB00EB">)</font><font color="#000000"> </font><font color="#000080">ifTrue:</font><font color="#000000"> <br>
                                                                                                                                        </font><font color="#EB00EB">[</font><font color="#808080">assignsToBlockArg</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#800000">true</font><font color="#EB00EB">]</font><font color="#EB8D00">]</font><font color="#00EB00">]</font><font color="#800000">]</font><font color="#800080">]</font><font color="#008000">]</font><font color="#000000">. <br>
                                        </font><font color="#808080">assignsToBlockArg</font><font color="#000000">] <br><br></font><font color="#000000"><i>CompiledMethod methods for debugger support</i></font><font color="#000000"> <br>
argumentCountForBlockAtPC: </font><font color="#000080">blockStartPC</font><font color="#000000"> <br>        </font><font color="#008080">&quot;Answer the argument count of the block whose first bytecode is startpc.&quot;</font><font color="#000000"> <br>
        (</font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">pcPreviousTo:</font><font color="#000000"> </font><font color="#000080">blockStartPC</font><font color="#000000">) </font><font color="#000080">ifNotNil:</font><font color="#000000"> <br>
                        [:</font><font color="#000080">closureCreationPC</font><font color="#808080">|</font><font color="#000000"> <br>                        </font><font color="#008000">[</font><font color="#800080">(</font><font color="#000000">InstructionStream </font><font color="#000080">on:</font><font color="#000000"> </font><font color="#800000">self</font><font color="#800080">)</font><font color="#000000"> <br>
                                        </font><font color="#000080">pc:</font><font color="#000000"> </font><font color="#000080">closureCreationPC</font><font color="#000000">; <br>                                        </font><font color="#000080">interpretNextInstructionFor:</font><font color="#000000"> </font><font color="#800000">nil</font><font color="#008000">]</font><font color="#000000"> <br>
                                        </font><font color="#000080">on:</font><font color="#000000"> MessageNotUnderstood <br>                                        </font><font color="#000080">do:</font><font color="#000000"> </font><font color="#008000">[</font><font color="#000000">:</font><font color="#000080">ex</font><font color="#808080">|</font><font color="#000000"> <br>
                                                        </font><font color="#000080">ex</font><font color="#000000"> </font><font color="#000080">message</font><font color="#000000"> </font><font color="#000080">selector</font><font color="#000000"> </font><font color="#000080">==</font><font color="#000000"> </font><font color="#000080">#pushClosureCopyNumCopiedValues:numArgs:blockSize:</font><font color="#000000"> </font><font color="#000080">ifTrue:</font><font color="#000000"> <br>
                                                                        </font><font color="#800080">[</font><font color="#800000">^</font><font color="#000080">ex</font><font color="#000000"> </font><font color="#000080">message</font><font color="#000000"> </font><font color="#000080">arguments</font><font color="#000000"> </font><font color="#000080">at:</font><font color="#000000"> </font><font color="#800000">2</font><font color="#800080">]</font><font color="#008000">]</font><font color="#000000">]. <br>
        </font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">error:</font><font color="#000000"> </font><font color="#800080"><font size="0.9" face="&#39;Accuny&#39;">&#39;pc is not a block start pc&#39; <br>
<br></font></font><font color="#000000">blockpcsToBlockExtents <br>        </font><font color="#008080">&quot;Answer a Dictionary of (Interval from startpc to lastpc) to (Interval of blockExtent), <br>         for the method and any blocks within it, using the identical numbering scheme described <br>
         in and orchestrated by BlockNode&gt;&gt;analyseArguments:temporaries:rootNode:. <br>         This is a variation on startpcsToBlockExtents whcih only answers startpc to interval.&quot;</font><font color="#000000"> <br>
        </font><font color="#808080">|</font><font color="#000000"> </font><font color="#6B6767">index</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"><br>        </font><font color="#6B6767">index</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#800000">0</font><font color="#000000">. <br>
        </font><font color="#800000">^self</font><font color="#000000"> <br>                        </font><font color="#000080">blockRangesAndExtentsInto:</font><font color="#000000"> Dictionary </font><font color="#000080">new</font><font color="#000000"> <br>
                        </font><font color="#000080">from:</font><font color="#000000"> </font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">initialPC</font><font color="#000000"> <br>                        </font><font color="#000080">to:</font><font color="#000000"> </font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">endPC</font><font color="#000000"> <br>
                        </font><font color="#000080">scanner:</font><font color="#000000"> (InstructionStream </font><font color="#000080">on:</font><font color="#000000"> </font><font color="#800000">self</font><font color="#000000">) <br>
                        </font><font color="#000080">numberer:</font><font color="#000000"> [</font><font color="#808080">|</font><font color="#000000"> </font><font color="#808080">value</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> </font><font color="#808080">value</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#6B6767">index</font><font color="#000000">. </font><font color="#6B6767">index</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#6B6767">index</font><font color="#000000"> </font><font color="#000080">+</font><font color="#000000"> </font><font color="#800000">2</font><font color="#000000">. </font><font color="#808080">value</font><font color="#000000">] <br>
<br>blockRangesAndExtentsInto: </font><font color="#000080">aDictionary</font><font color="#000000"> from: </font><font color="#000080">initialPC</font><font color="#000000"> to: </font><font color="#000080">endPC</font><font color="#000000"> scanner: </font><font color="#000080">scanner</font><font color="#000000"> numberer: </font><font color="#000080">numbererBlock</font><font color="#000000"> <br>
        </font><font color="#008080">&quot;Support routine for blockpcsToBlockExtents&quot;</font><font color="#000000"> <br>        </font><font color="#808080">|</font><font color="#000000"> </font><font color="#6B6767">extentStart</font><font color="#000000"> </font><font color="#6B6767">blockSizeOrLocator</font><font color="#000000"> </font><font color="#808080">|</font><font color="#000000"> <br>
        </font><font color="#800000">self</font><font color="#000000"> </font><font color="#000080">flag:</font><font color="#000000"> </font><font color="#800080"><font size="0.9" face="&#39;Accuny&#39;">&#39;belongs in DebuggerMethodMap&#39;</font></font><font color="#000000">. <br>
        </font><font color="#6B6767">extentStart</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#000080">numbererBlock</font><font color="#000000"> </font><font color="#000080">value</font><font color="#000000">. <br>
        [</font><font color="#000080">scanner</font><font color="#000000"> </font><font color="#000080">pc</font><font color="#000000"> </font><font color="#000080">&lt;=</font><font color="#000000"> </font><font color="#000080">endPC</font><font color="#000000">] </font><font color="#000080">whileTrue:</font><font color="#000000"> <br>
                        [</font><font color="#6B6767">blockSizeOrLocator</font><font color="#000000"> </font><b>:=</b><font color="#000000"> </font><font color="#000080">scanner</font><font color="#000000"> </font><font color="#000080">interpretNextInstructionFor:</font><font color="#000000"> BlockStartLocator </font><font color="#000080">new</font><font color="#000000">. <br>
                         </font><font color="#6B6767">blockSizeOrLocator</font><font color="#000000"> </font><font color="#000080">isInteger</font><font color="#000000"> </font><font color="#000080">ifTrue:</font><font color="#000000"> <br>
                                        </font><font color="#008000">[</font><font color="#800000">self</font><font color="#000000"> <br>                                                        </font><font color="#000080">blockRangesAndExtentsInto:</font><font color="#000000"> </font><font color="#000080">aDictionary</font><font color="#000000"> <br>
                                                        </font><font color="#000080">from:</font><font color="#000000"> </font><font color="#000080">scanner</font><font color="#000000"> </font><font color="#000080">pc</font><font color="#000000"> <br>
                                                        </font><font color="#000080">to:</font><font color="#000000"> </font><font color="#000080">scanner</font><font color="#000000"> </font><font color="#000080">pc</font><font color="#000000"> </font><font color="#000080">+</font><font color="#000000"> </font><font color="#6B6767">blockSizeOrLocator</font><font color="#000000"> </font><font color="#000080">-</font><font color="#000000"> </font><font color="#800000">1</font><font color="#000000"> <br>
                                                        </font><font color="#000080">scanner:</font><font color="#000000"> </font><font color="#000080">scanner</font><font color="#000000"> <br>                                                        </font><font color="#000080">numberer:</font><font color="#000000"> </font><font color="#000080">numbererBlock</font><font color="#008000">]</font><font color="#000000">]. <br>
        </font><font color="#000080">aDictionary</font><font color="#000000"> </font><font color="#000080">at:</font><font color="#000000"> (</font><font color="#000080">initialPC</font><font color="#000000"> </font><font color="#000080">to:</font><font color="#000000"> </font><font color="#000080">endPC</font><font color="#000000">) </font><font color="#000080">put:</font><font color="#000000"> (</font><font color="#6B6767">extentStart</font><font color="#000000"> </font><font color="#000080">to:</font><font color="#000000"> </font><font color="#000080">numbererBlock</font><font color="#000000"> </font><font color="#000080">value</font><font color="#000000">). <br>
        </font><font color="#800000">^</font><font color="#000080">aDictionary</font></span></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><div><font class="Apple-style-span" face="arial, helvetica, sans-serif">p.s. its my birthday today.  I should be doing something useful but this was too much fun, my present to myself.</font></div>
<div><font class="Apple-style-span" face="arial, helvetica, sans-serif"><br></font></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Cheers,<br><font color="#888888">
Juan Vuletich</font><div><div></div><div class="h5"><br>
<br>
Nicolas Cellier wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Writing to block arguments is considered bad practice.<br>
In most Smalltalk (all?), you cannot write method arguments.<br>
Since blocks are proper closures (introduced in Cuis 2.0) same rule<br>
now apply to block arguments.<br>
In squeak trunk, this behavior is driven by a Preferences, you can ask<br>
Juan if he applied same policy in Cuis.<br>
<br>
Anyway, [:sum :ea | sum := sum + ea] is completely useless since the<br>
variable sum cease to exist once the block closure finish execution.<br>
It has exactly same effect as [:sum :ea | sum + ea].<br>
<br>
This pattern was the result of some bad understanding of block return<br>
value and particularly the way inject:into: works, even in the<br>
pre-closure world.<br>
<br>
Cheers<br>
<br>
Nicolas<br>
<br>
2010/1/21 Phil (list) &lt;<a href="mailto:pbpublist@gmail.com" target="_blank">pbpublist@gmail.com</a>&gt;:<br>
  <br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I&#39;m attempting to get some code running on Cuis 2.0 and am having a problem<br>
with some pretty simple blocks like:<br>
<br>
[:sum :ea | sum := sum + ea] value: 1 value: 2.<br>
<br>
resulting in an error:<br>
<br>
[:sum :ea |  Cannot store into -&gt;sum := sum + ea] value: 1 value: 2.<br>
<br>
However, this example works without a problem in both 3.10.2 as well as 3.7.<br>
 Any idea what&#39;s going on?<br>
<br>
Thanks,<br>
Phil<br>
<br>
    <br>
</blockquote></blockquote>
<br>
<br>
</div></div></blockquote></div><br>