http://www.jsoftware.com/help/dictionary/dx013.htm
13!:19 y Cut Back. Cut back one stack level, stopping at the line at the
next stack level.
It's my belief that "cut back one stack level" should not run any code at
all. If it ran code, it would be doing something other than cutting back
the stack.
Now, it apparently is implemented at a detailed level, and apparently that
detail is not being handled properly in some cases. But that's something
that should be fixed.
But this is simple enough to test. We can define a script with some verbs
that contain loops:
v1=: 3 :0
for. i.4 do.
v2 y
end.
)
v2=: 3 :0
for. i.5 do.
v3 y
end.
)
v3=: 3 :0
for. i.6 do.
v4 y
end.
)
v4=: 3 :0
'breakpoint here'
)
13!:0]1
13!:3 'v4 0'
And, after loading this script, we can try it out:
v1 ''
|stop: v4
| 'breakpoint here'
|v4[0]
{."1]13!:13''
┌──┬──┬──┬──┐
│v4│v3│v2│v1│
└──┴──┴──┴──┘
13!:19''
|stop: v3
| v4 y
|v3[1]
{."1]13!:13''
┌──┬──┬──┐
│v3│v2│v1│
└──┴──┴──┘
13!:19''
|stop: v2
| v3 y
|v2[1]
{."1]13!:13''
┌──┬──┐
│v2│v1│
└──┴──┘
13!:19''
|stop: v1
| v2 y
|v1[1]
13!:19''
{."1]13!:13''
#13!:13''
0
So here, we can see that breakpoints work, and that cutting back the stack
does not care about loops.
That said, it occurs to me that the code I was using had callbacks from
external C code, and it might actually be the case that cutting back the
stack does not work across that kind of callback. I'll have to look into
that the next time I get one of these issues cropping up.
(If that turns out to be the problem, we should probably get at least a
paragraph of text in the documentation on dll.ijs or j's 'cd' command or on
the 15!: foreign about what code needs to properly support debugging from
within J. A book on debugging might not hurt, either.)
Thanks,
--
Raul
On Thu, Mar 13, 2014 at 11:52 AM, Michal Wallace
<[email protected]>wrote:
> You are running some code, and have triggered a breakpoint at stack depth
> 8, right?
>
> Then the (13!:19'') is meant to meant to run until the verb at level 8
> finishes, and pausing at the next instruction in level 7, right?
>
> And you're asking why you can walk up to levels 6, 5, and 4, but then
> suddenly find yourself back on level 8 instead of level 3...?
>
> So...
>
> I would guess that the original breakpoint at level 8 is in some explicit
> verb, which I'll pretend is called 'v'.
>
> It looks to me like the verb at level 4 is making two separate calls to
> 'v'. Perhaps it contains a loop?
>
> My hypothesis is that J is perfectly happy to pause at level 3 but doesn't
> because the breakpoint in 'v' is getting triggered a second time before the
> level 4 verb finishes.
>
> Of course this is all just a guess, since I can't actually see the code
> you're debugging. :)
>
>
>
> On Thu, Mar 13, 2014 at 8:49 AM, Raul Miller <[email protected]>
> wrote:
>
> > I think you are asking if the expression #13!:13''[(13!:19'') can somehow
> > add four levels of recursion onto the stack.
> >
> > And I think the answer is: that should not be possible.
> >
> > Thanks,
> >
> > --
> > Raul
> >
> >
> >
> > On Thu, Mar 13, 2014 at 7:58 AM, Michal Wallace <
> [email protected]
> > >wrote:
> >
> > > Is it possible that a breakpoint or error is triggering a break at
> level
> > 8
> > > before you reach level 4 again?
> > >
> > > On Mar 12, 2014 1:48 AM, "Raul Miller" <[email protected]> wrote:
> > >
> > > > #13!:13''[(13!:19'')
> > > > 4
> > > > #13!:13''[(13!:19'')
> > > > 8
> > > >
> > > > Something is wrong here. 13!:19 is supposed to cut back the stack.
> But
> > > > sometimes it fails and does something different.
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm