[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Quotient



Well, it is bullshit that // and - of one argument were motivated
by hardwre considerations.  How do you omit one argument to the FDVR
instruction?
Extension of nonassociative operators to other than two arguments
is always a tricky business.  There was confusion in FORTRAN for
quite a while over whether X/Y/Z should mean X/(Y/Z) or (X/Y)/Z = X/(Y*Z).
(FORTRAN 77 resolves this in favor of the latter.)
Now note that the definition of (QUOTIENT a b c ... z) = a/b/c/.../z
= (...((a/b)/c).../z) = a/(b*c*...*z) is not the only "natural" extension.
One could equally well define it to be a/b/c/.../z = a/(b/(c/...z)).
This is actually easier for the PDP-10 hardware given the LSUBR convention!
It is also what APL does when division-reduction is requested.
I strongly suspect that the real reason // and - are the way they are
is because of the appealing analogy to the standard infix and prefix
(i.e., binary and unary) interpretations of these operators.
Thus	(- x y) = x-y
 and	(- x)   = -x
which is certainly nice.  The three-or-more-argument cases arise seldom
anyway, so I suppose consistency for that extension was not a prime
concern.
Actually, the main argument for keeping three-argument - and //
in Common LISP is mostly compatibility, while there are good
arguments against (clarity).  One can just as well write (- x (+ y z))
as (- x y z).  (By the way, I think old PDP-1 LISP defined - and //
to work as APL reduction does.)  LISP 1.5 and InterLISP have only
two-argument quotient and difference.  Opinioc
xx opinions?
--Guy