The failing assert is a test on N which I introduced to prevent a stack error. The stack error is a consequence of the state machine defined by Kid -- it should be a tree, but was instead a directed graph containing a loop. These details are relevant for understanding what's happening here, but are a distraction from the problem.
The problem here is that cutting back the stack updates z. And, at the same time, it leaves the "current line" set to re-run the line which was executed to update z. -- Raul -- Raul On Thu, Jun 16, 2022 at 4:48 AM Henry Rich <[email protected]> wrote: > > The failing assert is line 0, right ? At that point local z has not been > set. Do you have a public definition somewhere? > > (Still away from computer) > > Henry Rich > > On Wed, Jun 15, 2022, 11:43 PM Raul Miller <[email protected]> wrote: > > > Sure, ... > > > > Kid=: 1 2,_ 1,:_ _ > > Key=: 94 48 92 > > Red=: 0 1 1 > > N=: 4 > > > > clean=: 3 :0 > > b=. (#y) > +/y e."1,9!:6'' > > }.}:b #inv b# |:y > > ) > > > > dbg=: 4 :0 > > echo clean^:2 ":x;('#',":#$y);('$',":$y);'';y > > ) > > > > > > safeshow=: 3 : 0 > > assert. 0 < N=:N-1 > > 1 dbg z=. '' > > assert. 1=#$z > > 'l r'=. y{Kid > > if. l<#Kid do. > > 2 dbg z=. '(',(safeshow l),') ' > > assert. 1=#$z > > end. > > 3 dbg z=. z,(":y{Key),':','BR'{~y{Red > > assert. 1=#$z > > if. r<#Kid do. > > 4 dbg z=. z,' (',(safeshow r),')' > > assert. 1=#$z > > end.EMPTY > > ) > > > > safeshow 0 > > 1 #1 $0 > > 1 #1 $0 > > 3 #1 $4 48:R > > 1 #1 $0 > > 3 #1 $4 48:R > > |assertion failure: safeshow > > > > After every assignment, z has a rank of 1, > > > > None of the assignments are from the result of safeshow. > > > > This suggests that cutting back the stack is implemented in an > > inconsistent fashion -- at least some of the time it may complete > > execution of the "current line" but despite that it leaves the code in > > a state which suggests that that "current line" has yet to be > > executed. > > > > Thanks, > > > > -- > > Raul > > > > On Wed, Jun 15, 2022 at 2:49 PM Henry Rich <[email protected]> wrote: > > > > > > Since I don't have a machine, I can't verify that anything is wrong. You > > > are failing in the third execution of show, using values that derive from > > > echo & might have rank 2. Why don't you type out the value of z at each > > > recursion? > > > > > > Henry Rich > > > > > > On Wed, Jun 15, 2022, 6:53 PM Raul Miller <[email protected]> wrote: > > > > > > > That missing final z would not be ok for 'safeshow' to function > > properly. > > > > > > > > But the problem here is not "how should 'safeshow' be changed to > > > > function properly?" -- the problem here is "how do we use the debugger > > > > to help us understand how J functions?" or perhaps "what is wrong with > > > > the debugger? / how do we get the debugger to work properly? / how do > > > > we understand J?" > > > > > > > > Specifically, why is z rank 1 for assert and echo when the computed > > > > result was rank 2? > > > > > > > > Thanks, > > > > > > > > -- > > > > Raul > > > > > > > > On Wed, Jun 15, 2022 at 1:49 PM Henry Rich <[email protected]> > > wrote: > > > > > > > > > > I am away from my machine, but I observe that the result of safeshow > > > > comes > > > > > from echo, not z. Is that ok? > > > > > > > > > > Henry Rich > > > > > > > > > > On Wed, Jun 15, 2022, 7:03 AM Raul Miller <[email protected]> > > wrote: > > > > > > > > > > > I am running into a problem, in J903 and J904 -- I haven't yet > > > > > > installed earlier versions of J on this machine. > > > > > > > > > > > > safeshow=: 3 :0 > > > > > > assert. 0 < N=:N-1 > > > > > > z=. '' > > > > > > assert. 1=#$z > > > > > > echo #$z > > > > > > 'l r'=. y{Kid > > > > > > if. l<#Kid do. > > > > > > z=. '(',(safeshow l),') ' > > > > > > assert. 1=#$z > > > > > > echo #$z > > > > > > end. > > > > > > z=. z,(":y{Key),':','BR'{~y{Red > > > > > > assert. 1=#$z > > > > > > echo #$z > > > > > > if. r<#Kid do. > > > > > > z=. z,' (',(safeshow r),')' > > > > > > assert. 1=#$z > > > > > > echo #$z > > > > > > end. > > > > > > ) > > > > > > > > > > > > Kid=: 1 2,_ 1,:_ _ > > > > > > Key=: 94 48 92 > > > > > > Red=: 0 1 1 > > > > > > N=: 3 > > > > > > safeshow 0 > > > > > > 1 > > > > > > 1 > > > > > > 1 > > > > > > |assertion failure: safeshow > > > > > > > > > > > > Now, there's a problem here with my data which triggers the > > assertion > > > > > > -- Kid should not contain any duplicate values other than _. But > > > > > > that's not what I am concerned with here. > > > > > > > > > > > > In Jqt, I enable debugging (control-K) and when the debugger pops > > up > > > > > > on the assert, I go back to the previous stack frame, and I find > > that > > > > > > z has rank 2, instead of rank 1. > > > > > > > > > > > > Specifically, it has the value '48:R',' (',:' ' > > > > > > > > > > > > So, now I am trying to figure out what's gone wrong. > > > > > > > > > > > > Conceptually, I could accept that z was being modified by virtual > > > > > > block handling -- except there's no update to z which would have > > given > > > > > > it a rank 2 value. > > > > > > > > > > > > Another possibility here is that there's something specifically > > wrong > > > > > > with my machine. So: can anyone else reproduce this issue? > > > > > > > > > > > > And, ... the next most likely possibility is that there's something > > > > > > wrong with the J engine itself. > > > > > > > > > > > > Anyways, I'd like to get someone else's perspective here. > > > > > > > > > > > > Thanks, > > > > > > > > > > > > -- > > > > > > Raul > > > > > > > > ---------------------------------------------------------------------- > > > > > > 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 > > ---------------------------------------------------------------------- > > 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
