1/ Yes, that's what I was missing.

2/ I can't always guarantee that my modified script verb will be used. I
have a rather involved set of scripts with dependencies and on many
occasions have tried to track down why a particular script was loaded.
(Hence my modified <script> verb).

My case:
 - 4!:8 seems simple, and consistent with J keeping track of things like
this with the other 4!:n foreigns.
 - The involvement of the interpreter is minimal -- when J appends a script
name to 4!:3, it also appends the current script index to 4!:8.
 - It solves my "who loaded this script" question directly, even for
scripts which are loaded outside of my direct control.
 - It reveals the entire "script call stack" which caused a particular J
name to be defined, not just the immediate script. (And allows the
construction of the entire script calling tree).

In short, it provides valuable information that J can keep easily, and I
can't.

If this isn't persuasive, I might be able to pull together a small bribe.
:)

/K


On Sun, Nov 24, 2019 at 3:51 PM Henry Rich <[email protected]> wrote:

> 1/ 4!:7 returns the previous value of the script index.  Isn't that enough?
>
> 2/ I would have you use a modified script verb.  Or, make the case very
> strongly for why you need 4!:8.  Currently the script index is stored
> only in names, not in the script-name list.
>
> Henry Rich
>
> On 11/24/2019 2:57 PM, Kirk Iverson wrote:
> > 1/ I'm trying to make use of these new script name foreigns and either
> I'm missing something or they are. My main problem is in the ability to pop
> the stack once the script which I have explicitly named has completed.
> >
> > 4!:6 seems to return the script index you've just named, and is a
> perfect argument to 4!:7. But once I'm done monkeying with things (eg with
> a 0!:100), how do I undo my recent 4!:7 -- I don't know what the previous
> script index was.
> >
> > For my purpose I'd like something that undoes the most recent 4!:7, or
> returns the current script index.
> >
> > Better still, I would like a dyadic form of 0!:k which accepts the
> script name in the left argument and sets it for the duration of its
> operation, so I don't have to worry about any of this stuff, eg:
> >     myscriptname 0!:100 myscriptcontents
> >
> >
> > 2/ While on the topic of these 4!:y foreigns, I'd also like to see one
> which returns a list parallel to 4!:3, but whose items identify the script
> which was running when the corresponding element of 4!:3 was added, eg:
> >
> >    4!:4 <'LF'    NB. index of script which defined <LF>
> > 2
> >     >2{4!:3 ''    NB. script name
> > C:\Users\kbi\j901\system\main\stdlib.ijs
> >     2{4!:99 ''   NB. script index which loaded stdlib
> > 1
> >
> > (Obviously, 0{4!:99 ''  would have to be something like _1 to indicate
> we're at the root).
> >
> > That way I can reconstruct the tree of scripts as they were loaded. I do
> something similar now with a hijacked <script> verb, but it doesn't catch
> everything.
> >
> > /K
> >
> > ----------------------------------------------------------------------
> > 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

Reply via email to