[R6RS] quotient, remainder, modulo
Michael Sperber
sperber at informatik.uni-tuebingen.de
Sun Apr 30 11:06:22 EDT 2006
Excutive summary:
- Extend `quotient' and `remainder' to arbitrary reals and make their
description consistent with that of `div' and `mod'.
- Ditch `modulo'.
Long version:
If you look in the current revision, you can see that the descriptions
for `div+mod' and `div0+mod0' are consistent in that they say:
(<div op> x1 x2) => nd
(<mod op> x1 x2) => xm
with x1 = nd * x2 + xm
where <div op> is either `div' or `div0', and <mod op> is the
corresponding `mod' or `mod0'. They only differ in the
characterization of which remainder / representative is chosen.
(If you wonder what the rationale for `div' and `mod' is, check the
thread at
http://srfi.schemers.org/srfi-77/mail-archive/msg00411.html
Bring some spare time.)
Now, `quotient+remainder' could be described in the same way. In
fact, the Scheme code from R5RS reproduced in the SRFI represents the
same equation. I propose that we do this, thus generalizing
`quotient+remainder' to arbitrary reals, just like `div+mod' and
`div0+mod0'.
The way the characterization is written provides the rationale why
`div' is paired with `mod', `div0' is paired with `mod0', and
`quotient' is paired with `remainder'. However, `modulo' has no dance
partner, and its usefulness is questionable---I've certainly never
seen a case where it was exactly the right thing and none of the
other three was. As the issue isn't complicated but confusing, I
suggest relegating `modulo' to the R5RS compatibility library and
getting rid of it for the regular R6RS.
Will argued for ditching `quotient' and `remainder' as well (as did
Sebastian Egner):
http://srfi.schemers.org/srfi-77/mail-archive/msg00420.html
However, Brad Lucier argues that we should keep `quotient' here:
http://srfi.schemers.org/srfi-77/mail-archive/msg00424.html
He also argues for providing a dance partner for `modulo', but no
explicit rationale.
--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
More information about the R6RS
mailing list