Article View: net.lang.apl
Article #30apl parsing
From: whuxlbech
Date: Wed, 07 Apr 1982 23:06
Date: Wed, 07 Apr 1982 23:06
41 lines
2142 bytes
2142 bytes
I think the hardest part of parsing APL is distinguishing
+/[X]-Y
from
A[X]-Y
Obviously, rabbit!ark is talking about HUMAN, rather than MACHINE, parsing.
The typical apl typein program creates internal ("Z-code") representation
by a left-to-right (sic) scan; in this case, it is simple to associate the
bracket expression with the thing (variable, intermediate value, or operator)
immediately to its left. I.e., by the time you "see" the -, you have either
absorbed the [...] into an operator (thus - is monadic) or into a value
(making - dyadic).
But as long as we are on the subject...my pet for the most confusing
(to a beginner, at least) aspect of apl is the large number of degenerate
objects; to someone with mathematical tendencies, it's a small price to
pay for the consistency of almost EVERYTHING, but consider:
goto iota 0
goto 0
goto
Each of which looks like "go to nothing," each of which has a quite distinct
and valuable meaning! To a more advanced apl'r, I submit that the most
common pitfall I run into is that some operators distinguish between a scalar
and a one-element vector (or higher order array), and some do not. Even if
one is possessed of a large store of apl arcana, it is easy to fall into
the following kind of trap:
VEC1 [ (SCALAR = VEC2) / VEC3 ] + VEC4
Quick: what is the result, assuming SCALAR appears exactly once in VEC2?
Answer: "LENGTH ERROR" -- the / operation, and hence the [], each return
a vector of length one which (in general) won't match the length of VEC4.
This particular kind of problem wouldn't be so bad except that I have
to use the kludge
((iota 0) rho vector_expression)
to explicitly "cast" the vector to a scalar.
By the way, I assume we're all "family" here. I cut my teeth on apl
in '67 on an old 1051 term my dad had connected to Yorktown, and have
been a fanatic since...anybody else wanna share their favorite gripes?
=Ned Horvath=
Technical Details
Message-ID:
<anews.Awhuxlb.205>Path:
arc1-ca.pugleaf.net!utzoo!decvax!harpo!zeppo!whuxlb!echShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!decvax!harpo!zeppo!whuxlb!ech From: whuxlb!ech Newsgroups: net.lang.apl Subject: apl parsing Date: Wed, 07 Apr 1982 23:06:40 +0000 Message-ID: <anews.Awhuxlb.205>