13!:0 also resets the stack.

-- 
Raul

On Tue, Aug 4, 2020 at 9:49 PM Devon McCormick <[email protected]> wrote:
>
> Bob's idea is better than mine.  Since I always have debug on, I did not
> notice the absence of a result from 13!:13.
> ownNameRT=: 3 : 0
>    rr=. a:
>    try. rr+1   NB. Cause error
>    catch. rr=. }:([}.~2+':'i.~])>{.<;._1]13!:12 '' end.
>    rr
> )
>    ownNameRT ''
> ownNameRT
>    dbr 0
>    ownNameRT ''
> ownNameRT
>    dbr 1
>    ownNameRT ''
> ownNameRT
>
> I did try to patch the 13!:13 method but am puzzled why it did not work:
> ownName=: 3 : 0
>    13!:0]1 [ svDbg=. 13!:17'' NB. Turn on debug after saving state of debug.
>    rr=. {.{.13!:13 ''         NB. What is my name?
>    13!:0]svDbg                NB. Reset debug to what it was.
>    rr
> )
>
>
> On Tue, Aug 4, 2020 at 9:22 PM 'robert therriault' via Programming <
> [email protected]> wrote:
>
> > Another option which does not require debug to be on is to embed the verb
> > in a try. catch. end. control block
> >
> >  tracer=: 4 : 0
> > try. x + y
> >  catch. 2 3 $ 'x arg';'Error Type';'y arg'; x;(, 13!:12 '');y end.
> > )
> >
> >     4 tracer 5
> > 9
> >    4 tracer 'a'
> > ┌─────┬──────────────────────────────────┬─────┐
> > │x arg│Error Type                        │y arg│
> > ├─────┼──────────────────────────────────┼─────┤
> > │4    │|domain error: tracer |   x    +y │a    │
> > └─────┴──────────────────────────────────┴─────┘
> >    'd' tracer 3
> > ┌─────┬──────────────────────────────────┬─────┐
> > │x arg│Error Type                        │y arg│
> > ├─────┼──────────────────────────────────┼─────┤
> > │d    │|domain error: tracer |   x    +y │3    │
> > └─────┴──────────────────────────────────┴─────┘
> >    2 3 tracer 3 4 5
> > ┌─────┬──────────────────────────────────┬─────┐
> > │x arg│Error Type                        │y arg│
> > ├─────┼──────────────────────────────────┼─────┤
> > │2 3  │|length error: tracer |   x    +y │3 4 5│
> > └─────┴──────────────────────────────────┴─────┘
> >
> > Cheers, bob
> >
> > > On Aug 4, 2020, at 17:21, Raul Miller <[email protected]> wrote:
> > >
> > > I cannot reproduce this result using the definition of ownName
> > > provided in this thread. So I am guessing you are using a different
> > > definition.
> > >
> > > I would recommend something like this:
> > >
> > > parentName=: 3 : 0
> > >   ;{.,}.13!:13 ''
> > > )
> > >
> > > ownName=: 3 :0
> > >  echo parentName ''
> > > )
> > >
> > > Which behaves like this:
> > >
> > >   ownName ''
> > >
> > >   dbr 1
> > >   ownName ''
> > > ownName
> > >
> > > Thanks,
> > >
> > > --
> > > Raul
> > >
> > >
> > > --
> > > zraaul
> > >
> > > On Tue, Aug 4, 2020 at 5:28 PM Brian Schott <[email protected]>
> > wrote:
> > >>
> > >> For more clarity, the session below shows the improvement after enabling
> > >> debug.
> > >>
> > >>   load 'debug'
> > >>   dbr 1
> > >>   ownName 9
> > >> 9
> > >> |ownName[0]
> > >> |       ownName 9
> > >> ----------------------------------------------------------------------
> > >> 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
> >
>
>
> --
>
> Devon McCormick, CFA
>
> Quantitative Consultant
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to