"david alis" asked: > How does one determine whether a noun stands for a mapped file?
I don't believe you can, currently. I made requests for such a mechanism months ago: http://www.jsoftware.com/jwiki/System/Library/Requests?action=diff&rev2=2&rev1=1 http://www.jsoftware.com/jwiki/System/Interpreter/Requests?action=diff&rev2=126&rev1=125 But, what you want differs subtly from what I want, and I believe your desires can be fulfilled: > Sections 46 and 47 of the Mapped File Lab demonstrate the need to > erase nouns that are aliases - but there is no advice about > determining which nouns are aliases. I want: given a name, tell me if it's mapped. You want: given a map, tell me its names. First, you should understand J's philosophy towards mapped nouns: You're supposed to keep track of them yourself. Asking the J interpreter "what are all my mapped nouns?" is as silly as asking the C compiler "what are all my int variables?". In both cases, the party-line response is: You assigned them; you should know! Of course, just as J realized that reflection on type is useful, we may realize that reflection on mapped-ness is useful. So, I've put together a small script. Get it here: http://www.jsoftware.com/svn/DanBron/trunk/general/unmaphard.ijs The primary utility you're interested in will be unmaphard_jmf_ . This finds all references to the mapped noun named in y , erases the names which contain those references, then unmaps the noun itself. The output is two boxes: the output of unmap_jmf_ y and the list of names which contained the references to the map. For example: require'jmf ~user\general\unmaphard.ijs' createjmf_jmf_ 4000 ;~ fn =: jpath '~temp\boo.jmf' map_jmf_'BOO';fn BOO =: (,'0'); 'hello' NB. Original mapped name. FOO =: BOO NB. Alias SNOO =: FOO & (4 : 'x') NB. Reference embedded in verb GOO =: BOO (2 : 'x u&v y') (4 : 'y') NB. Reference embedded in operator VALUES =: 3 : '5!:1{.;:y'&> allnames_jmf_ '' NB. References embedded in boxed noun NB. If you tried unmap_jmf_ 'BOO' right now, NB. you'd get 2 (indicating the reference count isn't 0) unmaphard_jmf_ 'BOO' +-+---------------------------------------------+ |0|+---------+---------+----------+------------+| | ||FOO_base_|GOO_base_|SNOO_base_|VALUES_base_|| | |+---------+---------+----------+------------+| +-+---------------------------------------------+ There's also unmapallhard_jmf_ which is the "hard" analog to unmapall_jmf_ . If you don't want to erase the offending names, but just see what's causing you trouble, instead of unmaphard_jmf_ use uh_LEAVE&unmaphard_jmf_ . This territory is treacherous, though. A small misstep could cause J to crash. For example: In theory, you could also use uh_COPY&unmaphard_jmf_ to leave the offending names unchanged, but remove their dependence on the mapped noun, or (uh_CHANGE;noun)&unmaphard_jmf_ to change all references to the noun to some other noun, but J's got bugs that make the former crash and the latter hang the interpreter. These bugs are a result of evading the philosophy I mentioned above. In fact, they're probably also the reason motivating its adoption: cleanly and confidently tracking all references (in both directions) to a mapped noun is hard. So, were I you, I'd only use unmaphard_jmf_ for debugging (find places you unwittingly created references) and ad-hoc scripting. Don't use it in a production system. Once you've debugged your scripts, keep explicit track of the names you map and any references to them. -Dan ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
