Cleanup Issue EXPT-ZERO-ZERO
- Status
- For Internal Discussion
- Forum
- Cleanup
- Category
- CHANGE
- References
- EXPT (pp203-204)
Problem Description
(expt 0 0) is mathematically undefined, but CLtL defines it as being 1 in most cases.Proposal (MAKE-UNDEFINED)
Make (expt 0 0) an error for zeros of all types. That is, it has ``undefined effect.''Test Cases
(EXPT 0 0) => 1 ;according to CLtL
(EXPT 0 0) is undefined ;proposed
Rationale
0 For some examples of the behavior of 0 , consider:
X 1) Lim 0 = 0 X->0
ln k 2) Y(X) = -------- c + ln X
Lim Y(X) = 0 X->0
but
Y(X) Lim X = k x->0
Current Practice
Symbolics Genera returns 1 for the test case.Cost to Implementors
Technically, there is no cost to implementors because this would become an ``is an error'' situation, and all implementations that already conform would continue to conform.
In practice, most implementations would want to detect the error in high safety situations. In most cases, this is a straightforward change to one or two functions, and including perhaps some compiler optimizers. If any implementations have microcoded this operation, the change may be more complicated.
Cost to Users
Even though some implementations might not change, users would not be able to depend on this feature in portable code. Given the mathematical questionableness of the behavior, however, some of the affected users may treat a trend toward error detection as a `bug fix.'Cost of Non-Adoption
Some mathematical errors will not be detected because CL supplies a value which is not always appropriate.Benefits
In implementations which choose to reliably signal an error in this case, condition handling can be used to customize the behavior of (expt 0 0) in a manner appropriate to the application.Aesthetics
Cleaner mathematically.Discussion
We'd really prefer one of ``must signal'' or ``should signal,'' but since non-integer 0 powers are already ``is an error'' this is most consistent.
Cyphers, Pitman, and several other Lisp developers at Symbolics think this is a good idea.
Edit History
- 27-Feb-89, Version 1 by Scott Cyphers (Cyphers@Symbolics.COM),
- 27-Feb-89, Version 2 by Pitman (signals->is an error, misc edits)