Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!torsqnt!geac!itcyyz!yrloc!hui
From: hui@yrloc.ipsa.reuter.COM (Roger Hui)
Subject: Re: 'Locatives' in J
Message-ID: <1992Apr12.194423.1445@yrloc.ipsa.reuter.COM>
Keywords: J locale locative
Organization: Iverson Software Inc.
References: <1992Apr9.145907.1041@apollo.hp.com>
Date: Sun, 12 Apr 92 19:44:23 GMT

Mark Keil writes:
>  [ some lesson 18 stuff deleted ]
>
> I had read lession 18, and I felt I was missing something.
> I still feel that I am missing something.
 
This is one reason why I dislike talking about future plans and features
not yet available, because if locatives had been implemented you can obtain
answers to these questions by consulting an oracle much more patient and
much more accurate than I.  Since my first answer was unsatisfactory,
any other answers I provide will probably be unsatisfactory as well.
But one last try:
 
I am re-introducing the text from An Introduction to J, the "[some lesson
18 stuff deleted]" above, because it really does answer the questions.
 
[ 0] A name that includes an underbar (_) is a locative.  Names used in a
[ 1] locale F can be referred to in another locale G by using the prefix F
[ 2] in a locative name of the form F_pqr, thus avoiding conflict with
[ 3] otherwise identical names in the locale G.
[ 4]
[ 5] The referent of a locative can be established in either of two ways:
[ 6]
[ 7] a) By assignment, as in F_pqr=. i. 5 .
[ 8]
[ 9] b) By saving a session in the manner discussed in Lesson 11; the names
[10] established in the session can thereafter be referred to by using the
[11] locale as a prefix in a locative name.  For example:
[12]    names=. 4!:1
[13]    copy=. 2!:4
[14]    save=. 2!:2
[15]    save <'TOOLS'
[16] 1
[17]    4!:55 names 3
[18] 1 1 1
[19]    TOOLS_copy <'TOOLS'
[20] 1
[21]    names 3
[22] +----+-----+----+
[23] |copy|names|save|
[24] +----+-----+----+
 
> Just what is the J definition of a locale?
 
A "locale" is something which can:
. be named (F and G [1-2])
. be referenced in a locative (F_pqr [2])
. contain named objects (pqr [2])
 
Or, if you prefer,  Definition: A locale is a named set of names.
 
> What are the undelying semantics/abstraction of a locale?
> When a referant of a locative is established by assignment,
> what is is happening in the object name space?
 
I don't know what these mean.  (What is "underlying semantics"?
Underlying abstraction?  Object name space?)  I am assuming that these
are alternative ways of asking "what properties does it have", already
partly answered above and further elaborated below.
 
> Do these things have ant special propreties?
 
The following properties can be inferred:
 
. Different locales can contain identical names without conflict [2-3,17,19].
. Unprefaced names in a locale are interpreted w.r.t. that locale [0-3].
. A locale can be established by assigning to a name containing a _ [7].
. If a locale F already exists, assigning to a locative F_pqr=.i.5
  merely adds pqr to F or, if pqr already exists in F, changes the
  referent of pqr [5,7].
. Names in a locale can be referenced by locatives [2,19], for example
  NonLocative @ F_pqr @ Tlc_wxyz.
. A locale can be established by saving a "workspace", i.e. those objects
  named in the right arguments of verbs derived from 2!: [9-15].
 
> Are there any side effects of using "_" in a name just for calrity?
 
A name containing _ would be a locative [0,7]; this would be the case
however the name came to have an _, for clarity, for style, for whatever.
When locatives are finally implemented this would (alas) introduce an
incompatibility with existing names containing _.

------------------------------------
Roger Hui, Iverson Software Inc., 33 Major Street, Toronto, Ontario  M5S 2K9
Phone: (416) 925 6096;  Fax: (416) 488 7559
