[net.lang] Merry APL, a subtle error

donald@utcsrgv.UUCP (Don Chan) (11/17/83)

The recent submission of
    (15,rho S) rho S <- 'Merry Christmas'
as a way of printing "Merry Christmas" 15 times is technically
wrong, although it would probably work on most implementations.

The error is rather subtle, stemming from a misinterpretation of
the order of evaluation rules.  APL operators are *right associative*
but the order of *operand fetching/evaluation* is not defined!
Thus, the "S" value referred to in "rho S" is not necessarily the "S"
value that has just been assigned.

Put another way, the value of "I+I<-1" is undefined in APL, not
2 as most people might say.  Think of it as "I+(I<-1)" and recall
that in any expression "F+G" the order of evaluation of F and G
is not defined (and rightly so!  it's nice to have unbounded
parallelism)

Of course, when operands have no side effects none of this matters,
as applicative programmers smugly point out.
-- 
Don Chan, University of Toronto Department of Computer Science
ARPAnet: utcsrgv!donald@UW-BEAVER
UUCP:    { utzoo linus ihnp4 floyd allegra uw-beaver
           ubc-vision cornell watmath hcr decwrl }!utcsrgv!donald