Devon wrote:
I plan to add this to my "WS.ijs" module at some point unless someone
else beats me to it.

I would make a couple of suggestions. WS.ijs would be more useful if you broke up the new code into several utilities.

The primary utility would be a dyad whose RHA is a filename, and whose LHA is a list of fully-qualifed J names. The dyad would store the definitions x in the file named by y .

Of course you'll need a second utility monad, which given a list of FQJNs, produces their definitions.

On top of that, you'll should have a dyad which, given a locale specification x and a list of nameclasses y , would returns the FQJNs of all entities in the specified locales with the specified nameclasses (or '' for all nameclasses).

Another useful utility would be one which produces the FQJNs of the entities which have changed since its last invocation (i.e. 4!:5). That way, one could do "incremental" workspace backups.

The last, probably most useful, utility would be a filter a filter to determine which names were not defined in scripts.

As you, yourself, pointed out: names defined by a script need not and should not be stored again (except maybe for emergency backup purposes). An easy way to determine if a name was defined in immex would be if _1 -: 4!:4 .

I've coded all this up at

   http://www.jsoftware.com/svn/DanBron/trunk/environment/fqn.ijs

Feel free to incorportate these definitions into your WS.ijs. Cherry pick if you so desire. I commented the script a little bit, but I'm too lazy to put in useful examples (my normal procedure for "production" code). So if you have questions/concerns/comments, please just ask.

Here, briefly, is how one could use FQN stand alone (i.e. independent of WS.ijs). Create a new script, and put these lines at the top:

           require 'fqn.ijs'

           NB.  A "workspace" in which to store names.
           NB.  Could easily generate a new JWS file
           NB.  per session, a-la J's temp scripts.
           f     =: jpath '~temp\session.jws'

           NB.  Intialize:  store all names not defined by the
           NB.  system (the standard J library). The  ^:
           NB.  is so that we can reload this script without
           NB.  re-storing all names.
           f saveNames^:(verb ~: nc{.;:'incremental')~ 2 allnames ''

           NB.  Utility verb:  Call it to store all the names changed since it
           NB.  it was last called (if your code uses 4!:5 , this will be
           NB.  incomplete).
           incremental =: f saveDelta
           incremental '' NB.  Start observing name changes.

now, whenever you feel the need to take a "snapshot of your workspace", type incremental '' .

-Dan

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to