[comp.lang.apl] what makes the atomic rep so special?

mjab@nanna.think.com (Michael J. A. Berry) (03/01/91)

I have been tearing my hair trying to debug a gnu emacs j-interaction mode
so I can post it here. An important feature of this emacs mode is that when
you say meta-control-g (remember where del used to live?), it pops up two
little windows containing, respectively the monadic and dyadic definitions
of a j verb.  You than edit these to your heart's content in a familiar
environment where each line in the buffer represents a separate J
statement.  You are free to leave either buffer empty if your verb only
has a monadic (or dyadic) definition.  It's all very nice except that it
doesn't work.

My problem is that when I get emacs to construct what look to me like
perfectly good atomic representations, the fix adverb (5!:0) barfs on them.
Does anyone know what secret thing makes an atomic rep different from what
I am building?  I can make my editor work by giving up on fix and having
emacs send apl an input string with lots of doubled quotes and a ::
somewhere in the middle, but out of pure intellectual curiosity, I still
want to know how to build my own atomic representations.  

Here's what I'm doing that doesn't work:

================= from J 2.9 session on Sun 4 ========================

   mg
z=. 2  
z $: y.
   dg
x. * y.
   $dg
1 7
   
   mg build_ar dg
+------------------------------+
|+--+-------------------------+|
||::|+-----------+-----------+||
||  ||+-+-------+|+-+-------+|||
||  |||0|z=. 2  |||0|x. * y.||||
||  ||| |z $: y.||+-+-------+|||
||  ||+-+-------+|           |||
||  |+-----------+-----------+||
|+--+-------------------------+|
+------------------------------+
   (mg build_ar dg) FIX
domain error
   
   real =. ar 'goo'
   real
+------------------------------+
|+--+-------------------------+|
||::|+-----------+-----------+||
||  ||+-+-------+|+-+-------+|||
||  |||0|z=. 2  |||0|x. * y.||||
||  ||| |z $: y.||+-+-------+|||
||  ||+-+-------+|           |||
||  |+-----------+-----------+||
|+--+-------------------------+|
+------------------------------+
   
   goo2 =. real FIX
   goo2 4
8
   
Here is the function I am using to make the fake
atomic reps:

   build_ar
+---------+--+--------------------------------+
|x. $: i.0|::|< '::'; < (< (,0);x.) ,< (,0);y.|
+---------+--+--------------------------------+
   

Thanks for any help,   
Michael
--

==============================================
Michael J. A. Berry

Internet:  mjab@think.com
uucp:      {harvard, uunet}!think!mjab
telephone: (617) 234-2056  FAX: (617) 234-4444
==============================================

hui@yrloc.ipsa.reuter.COM (Roger Hui) (03/02/91)

Hello Michael. Sorry about your hair. To get immediately to the point:
The "id" parts of the representation must be the string ,'0', whereas
you were using numeric vector 0. i.e. the verb build_ar should be
 
  build_ar=. 'x.$: i.0' : '<''::''; <(<(,''0'');x.), <(,''0'');y.'
 
The id part of atomic representations are always strings, ('::', '+',
etc.), and representations of nouns are no exception. Atomic
representations returned by 5!:1 have no hidden attributes, and can be
constructed by other means, as in your msg.
 
For the purpose you had in mind, an emacs editor for a ::-defined verb,
there is another (easier) approach.  One can use 5!:2 (display
representation) to get the monadic and dyadic defns, and :: to
reconstitute the edited results.  For example,
  dr  =. 5!:2
  t   =. dr <'goo'
  mg  =. >0{t
  dg  =. >1{t
  x   =. mg emacs dg
  mg  =. massage0 x
  dg  =. massage1 x
  goo =. mg :: dg
 
Atomic representation (5!:0) is designed for automatic manipulations,
e.g. the basis for gerundial forms. It is somewhat of an internal
representation and is subject to change.
 
Roger Hui
Iverson Software Inc.
33 Major Street
Toronto, Ontario  M5S 2K9
(416) 925 6096