ANSI #raisedToInteger:
Richard A. O'Keefe
ok at cs.otago.ac.nz
Tue Dec 17 03:00:05 UTC 2002
I've now got a copy of the published version of the ANSI Smalltalk
standard. Has too much study driven me mad, or is the following
method description seriously broken?
5.6.2.28 Message: raisedToInteger: operand
Synopsis
Answer the receiver raised to the power operand.
Definition: <number>
Answer the receiver raised to the power operand,
which must be a whole number.
If the operand is a whole number greater than or equal to zero,
then the result is the receiver raised to the power operand.
>>> If operand is a negative whole number, then the result is
>>> equivalent to the reciprocal of the absolute value of the
>>> receiver raised to the power operand.
...
The highlighted sentence is ambiguous.
Suppose we have (p raisedToInteger: q) where p is a positive
integer and q is a negative integer.
Reading 1:
The result is ... the reciprocal of ((the absolute value of
the receiver) raised to the power operand).
^((self abs) raisedToInteger: operand) reciprocal
Reading 2:
The result is ... (the reciprocal of (the absolute value of
the receiver)) raised to the power operand.
^(self abs reciprocal) raisedToInteger: operand
Surely it should be
The result is ... (the reciprocal of the receiver) raised to
the power (the absolute value of operand).
^self reciprocal raisedTo: operand abs
or else
The result is ... the reciprocal of (the receiver raised to
the power (the absolute value of operand)).
^(self raisedTo: operand abs) reciprocal
There are other glitches I laughed at in the 1.9 draft, but
they don't seem quite as funny when I've paid for the final version
and they are still there.
More information about the Squeak-dev
mailing list
|