Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!news-server.csri.toronto.edu!torsqnt!jtsv16!itcyyz!yrloc!hui
From: hui@yrloc.ipsa.reuter.COM (Roger Hui)
Subject: Re: J? on Matrix Trans
Message-ID: <1992Feb15.080719.365@yrloc.ipsa.reuter.COM>
Organization: Iverson Software Inc.
Date: Sat, 15 Feb 92 08:07:19 GMT

Raul Rockwell writes (regarding why |."1!.0 signals error):
 
> Think of it this way:  customize simply takes its verb argument and
> looks it up in a table.  If it's in the table, it builds a new
> function according to whatever rules it found in the table.  If it's
> not in the table, it's a domain error.  The alternative would be to
> have customize analyze the internal structure of a verb with is
> arbitrarily complex.
>
> To recognize verbs defined using " you'd probably want a secondary
> table lookup after the first one fails.  You don't want to put every
> single verb derivable using " into the table -- you just want to
> recognize that a conjugation with a noun is present, which means that
> !. should be applied (recursively) to the base verb.  Except for one
> thing -- in an interpretive environment this is likely to be slow.
 
Fit (!.) is implemented by a branch table (a switch statement) in source 
file cf.c.  The fact that |."r!.0 is not recognized is only because the 
current implementation did not see fit to recognize it.  There is nothing 
to prevent it in principle; in fact, there is nothing particularly difficult 
about recognizing this case.  (Apologia: I can't implement everything that 
can be imagined :-)
 
There is an analogous situation in obverse (^:_1), implemented in file
ai.c.  The system recognizes obverses of primitive verbs, as well as verbs
of the form n&v and v&n, v/\ and v/\., v~, and others, for many different v's.
It is not necessarily slow: in computing the obverse, arbitrarily complex
logic may be employed, but this is done once; in usage, the resultant
obverse verb is no more expensive than other verbs.

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