Newsgroups: comp.lang.apl
Path: watmath!watserv1!utgpu!csd.unb.ca!morgan.ucs.mun.ca!nstn.ns.ca!news.cs.indiana.edu!mips!zaphod.mps.ohio-state.edu!malgudi.oar.net!news.ans.net!yktnews!admin!gerth
From: gerth@watson.ibm.com (John Gerth)
Subject: Re: APL slash bang (Repost)
Sender: news@watson.ibm.com (NNTP News Poster)
Message-ID: <1992Mar27.133322.10579@watson.ibm.com>
Date: Fri, 27 Mar 1992 13:33:22 GMT
Distribution: us
Reply-To: gerth@watson.ibm.com
Disclaimer: This posting represents the poster's views, not necessarily those of IBM
References:  <920327075654_70530.1226_CHC88-1@CompuServe.COM>
Nntp-Posting-Host: minnie.watson.ibm.com
Organization: IBM T.J. Watson Research Center

In article <920327075654_70530.1226_CHC88-1@CompuServe.COM>, Mike Kent <70530.1226@CompuServe.COM> writes:
|> 
|> Main frame APL2 has an external function (accessed via []na) called, as I
|> recall, ATN.  It is _somewhat_ similar to []fi; the mmain diffference is
|> that it attempts (and fails, IMO) to incorporate part of the functionality
|> of []vi as well.  When all the (blank-delimited) substrings of a string S
|> are valid representations of numbers, it is the same as   []fi S    (or
|> execute S), but when at least one substring in not convertible (i.e., when
|> []vi S    contains at least one 0), the result is either empty or 0, I
|> forget which.  

The function name is CTN (character-to-numeric), otherwise all rocks are
appropriately thrown.  The result when conversion fails due to invalid
strings is an empty vector.  It's nearly the same as doing Execute against
the character vector except that failure doesn't blow up and incorrect input
which accidentally parses to an valid expression won't be executed.

As the author of this arguablty brain-dead hack, I will attempt to explain
where it came from rather than whether it is of value.  The original business
case for []NA was to call FORTRAN routines.  Some of us argued (successfully)
that the right model was to make function calls.  This held the prospect of
permitting us to add required function, ala []FI without the glacial timescales
associated with change to the language.  So why was CTN done?  The answer
was pure opportunism on my part.  Since APL2 attempts to preserve the 
input form of numeric constants in functions, it had originally been built
to store the character vectors for those constants as "names" in the symbol
table.  But lots of people use Execute to convert strings read from files
into numbers, so the prototype system could get VERY large symbol tables.
As a result of that the tokenizer had a flag which Execute used saying
"look, if this parse results in only a numeric constant don't put it in
the symbol table and don't build the token string".  In the frenzy at the
end of the release cycle, I felt we could get a useful part of the []FI
functionality by having an external function call-back to APL and use 
this Execute-like interface to get robust conversions.  In the future we
could add better diagnostics for the error situations.  In and of itself,
CTN was a mistake, it did however introduce the notion of "call-back" to
APL from the outside, which was later implemented for arbitrary expressions.
 
-- 
/John
