Been experimenting with mapped files...
Looking for a reliable way to detect if a mapped file has changed
since I last inspected it.

If pronoun: TITLE is mapped to a file, then
   sav=: TITLE
will create: sav -as not a copy but an alias of TITLE. (Not
surprisingly, because they share the same memory.)

Thus reassigning sav will change TITLE too, and vice-versa. Which
makes: sav=:TITLE no good as a way of snapshotting TITLE to detect
changes.

1. Can you think of a low-overhead verb: own -used like so:
   sav=: own TITLE
-which will force J to allocate sav its own separate space in memory?

I've tried these:
own=: ]
own=: [: > [: {: 0 ; <
own=: $ $ ]

The first 2 don't work: sav keeps in step with TITLE, thanks to J's
optimisation.
The third defn works --but for how much longer? At some future date it
might break, thanks to improved J optimisation.

2. Is there a more elegant way of checking whether a mapped file has changed?

   When I change a mapped noun I cannot see any changes to:
showmap_jmf_'' --this is on a Mac.
   I can repeatedly read the directory entry using 1!:0 and watch for
it to change (as its timestamp gets updated). The processing overhead
is tolerable, but is it the best I can do?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to