<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 21, 2014 at 2:26 AM, Frank Shearar <span dir="ltr">&lt;<a href="mailto:frank.shearar@gmail.com" target="_blank">frank.shearar@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 20 January 2014 23:47, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>

&gt; Hi Frank,<br>
&gt;<br>
&gt;<br>
&gt; On Mon, Jan 20, 2014 at 2:01 PM, Frank Shearar &lt;<a href="mailto:frank.shearar@gmail.com">frank.shearar@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; I often use Blocks for holding tiny bits of state not worth<br>
&gt;&gt; formalising as a class. As a result, I often get this error because I<br>
&gt;&gt; also spend a lot of time developing in the Debugger.<br>
&gt;&gt;<br>
&gt;&gt; Is the following a completely crazy idea?<br>
&gt;&gt;<br>
&gt;&gt; self selectedContext activeHome ifNil: [ |ctxt|<br>
&gt;&gt;     ctxt := self selectedContext.<br>
&gt;&gt;     &quot;look up ctxt method methodClass &gt;&gt; ctxt selector.&quot;<br>
&gt;&gt;     &quot;Save the code as normal&quot;<br>
&gt;&gt;     ctxt method become: ctxt method methodClass &gt;&gt; ctxt selector].<br>
&gt;<br>
&gt;<br>
&gt; All but the last line is sane ;-)  You can&#39;t expect a become: to do the<br>
&gt; right thing. It&#39;ll leave the context&#39;s pc wrong, and perhaps its stack<br>
&gt; pointer too.  You&#39;re looking for<br>
&gt;<br>
&gt;     ctxt privRefreshWith: ctxt method methodClass &gt;&gt; ctxt selector<br>
&gt;<br>
&gt; But what do you want to do?  Are you rewriting a block as a block or as a<br>
&gt; method?  What yu have above will do the latter, not the former.<br>
<br>
</div>Surely the wrongness of the pc doesn&#39;t matter? When you<br>
edit-and-continue a method (as opposed to a block in a method), the<br>
&quot;continue&quot; part resumes at the start of the method. Unless you mean<br>
that, with this block, you&#39;d need to position the pc _at the start of<br>
the block_, or similar?<br></blockquote><div><br></div><div>Right.  That&#39;s what privRefresh does; reset the pc and the stack pointer to the relevant values for the beginning of the method or block.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
But the use case is this: I have a method that returns a block that<br>
generates values. I don&#39;t have the source to hand right now, but it<br>
goes something like this:<br>
<br>
makeGeneratorFrom: aSymbol<br>
    | base current |<br>
    base := aSymbol. current := -1.<br>
    ^ [current := current + 1.<br>
        (base , current asStringg) asSymbol]<br>
<br>
and then in the class I can say<br>
genny := self makeGeneratorFrom: #z.<br>
{genny value. genny value} &quot;=&gt; {#z0. #z1}&quot;<br>
<br>
If I see a bug - the deliberate #asStringg typo - the debugger pops<br>
up, I correct the code, and then can&#39;t save the change because<br>
#makeGeneratorFrom: isn&#39;t in the call stack. What I&#39;d like is to (a)<br>
save my change at all (rather than copy all the source, open a<br>
Browser, find the right method, paste the source, accept), and (b)<br>
have execution continue with the new version of the block.<br>
<br>
(And a &quot;wrinkle&quot; (he says naively) is that to edit-and-continue here,<br>
the new BlockContext (or whatever) would need to have references to<br>
the variables closed over by the old BlockContext.)<br></blockquote><div><br></div><div>[BTW, BlockContext isn&#39;t used any more.  Only MethodContext, which is now misnamed and should be renamed to Context.  Block and method activations are differentiated by blocks having a non-nil closureOrNil inst var].</div>
<div><br></div><div><br></div><div>So the change to the method is easy, but replacing the activation more difficult, simply because of the necessary UI plumbing.  BlockClosure&gt;&gt;asContextWithSender: does almost all you need (it doesn&#39;t push arguments) tio generate the activation.  You&#39;ll have to figure otu how to plumb that nto the debugger.</div>
<div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Even if I can&#39;t edit-and-continue this, at the least I&#39;d like to save<br>
the source from within the Debugger, and possibly abandon the Process.<br></blockquote><div><br></div><div>Sure.  That&#39;s all about hacking out the warning in some way you can live with.</div><div><br></div><div>Please report back.  This is intriguing :)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
frank<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
&gt;&gt; You&#39;d need to fiddle the stack pointer, but that you have to do anyway<br>
&gt;&gt; in edit-and-continue.<br>
&gt;&gt;<br>
&gt;&gt; frank<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; best,<br>
&gt; Eliot<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>best,<div>Eliot</div>
</div></div>