I second your wish; I've made a similar request. A simple, safe way to test if
a name is local is to see if it appears in the
name list:
--- file: ~temp\40.ijs ---
NB. NARGLE =: ; 4!:5&.> i.2
A_LOCAL_NOUN =. 1 2 3
A_GLOBAL_NOUN =: 1 2 3
A_LOCAL_VERB =. +/
A_GLOBAL_VERB =: +/
A_LOCAL_ADV =. /
A_GLOBAL_ADV =: /
A_LOCAL_CONJ =. @
A_GLOBAL_CONJ =: @
NB. NARGLE =: ; 4!:5&.> i.-2
NB. Name of current locale
here =: coname ''
NB. All names visible from here
ALL_NAMES =: ; 3 : '<nl__y 0 # , y =. y. '"0 here , |. copath here
NB. We'd get these from the definition...
names_to_test =: ;: 'A_GLOBAL_ADV A_GLOBAL_CONJ A_GLOBAL_NOUN
A_GLOBAL_VERB A_LOCAL_ADV A_LOCAL_CONJ A_LOCAL_NOUN
A_LOCAL_VERB'
smoutput names_to_test -. ALL_NAMES
--- Run in session ---
load '~temp\40.ijs'
+-----------+------------+------------+------------+
|A_LOCAL_ADV|A_LOCAL_CONJ|A_LOCAL_NOUN|A_LOCAL_VERB|
+-----------+------------+------------+------------+
Note that using coname'' is sufficient, because even f. doesn't handle
names in other locales:
foo_AA_ =: +/
bar_AA_ =: foo % #
bar_AA_ f.
|value error: foo
| bar_AA_ f.
I suppose we could improve upon f. , but then we'd have to handle names like
foo__A__B__C , etc.
An alternative approach is to bracket your block of local definitions with
4!:5[1 , which will return the global, but not local,
names that have changed within that block. The advantage is the names so
returned are fully qualified (with the locale).
The disadvantage is the burden is put upon the user to use 4!:5 and provide
its results as the RHA to the (conjunction) F .
Though making F a conjunction like that has the benefit that the user can
precisely control which names are fixed.
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm