[squeak-dev] 'Method for block not found on stack, can''t edit and continue'

Frank Shearar frank.shearar at gmail.com
Tue Jan 21 10:26:31 UTC 2014


On 20 January 2014 23:47, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> Hi Frank,
>
>
> On Mon, Jan 20, 2014 at 2:01 PM, Frank Shearar <frank.shearar at gmail.com>
> wrote:
>>
>> I often use Blocks for holding tiny bits of state not worth
>> formalising as a class. As a result, I often get this error because I
>> also spend a lot of time developing in the Debugger.
>>
>> Is the following a completely crazy idea?
>>
>> self selectedContext activeHome ifNil: [ |ctxt|
>>     ctxt := self selectedContext.
>>     "look up ctxt method methodClass >> ctxt selector."
>>     "Save the code as normal"
>>     ctxt method become: ctxt method methodClass >> ctxt selector].
>
>
> All but the last line is sane ;-)  You can't expect a become: to do the
> right thing. It'll leave the context's pc wrong, and perhaps its stack
> pointer too.  You're looking for
>
>     ctxt privRefreshWith: ctxt method methodClass >> ctxt selector
>
> But what do you want to do?  Are you rewriting a block as a block or as a
> method?  What yu have above will do the latter, not the former.

Surely the wrongness of the pc doesn't matter? When you
edit-and-continue a method (as opposed to a block in a method), the
"continue" part resumes at the start of the method. Unless you mean
that, with this block, you'd need to position the pc _at the start of
the block_, or similar?

But the use case is this: I have a method that returns a block that
generates values. I don't have the source to hand right now, but it
goes something like this:

makeGeneratorFrom: aSymbol
    | base current |
    base := aSymbol. current := -1.
    ^ [current := current + 1.
        (base , current asStringg) asSymbol]

and then in the class I can say
genny := self makeGeneratorFrom: #z.
{genny value. genny value} "=> {#z0. #z1}"

If I see a bug - the deliberate #asStringg typo - the debugger pops
up, I correct the code, and then can't save the change because
#makeGeneratorFrom: isn't in the call stack. What I'd like is to (a)
save my change at all (rather than copy all the source, open a
Browser, find the right method, paste the source, accept), and (b)
have execution continue with the new version of the block.

(And a "wrinkle" (he says naively) is that to edit-and-continue here,
the new BlockContext (or whatever) would need to have references to
the variables closed over by the old BlockContext.)

Even if I can't edit-and-continue this, at the least I'd like to save
the source from within the Debugger, and possibly abandon the Process.

frank

>> You'd need to fiddle the stack pointer, but that you have to do anyway
>> in edit-and-continue.
>>
>> frank
>>
>
>
>
> --
> best,
> Eliot


More information about the Squeak-dev mailing list