Edit history: 2004-07-20, Version 1 by Bruno Haible
Status: For CLiki consideration
- Problem Description:
- CLHS 18.104.22.168 and UPGRADED-ARRAY-ELEMENT-TYPE imply that all implementations must support arrays of element type NIL. These are strange beasts: On one hand they are (if one dimensional) STRINGs. On the other hand any AREF access to an element must give an error, because there is no object of type nil. Thus they don't behave like normal arrays or sequences.
- Proposal (ARRAY-ELEMENT-TYPE-NIL:EXCLUDE):
Modify the semantics of :(CLHS UPGRADED-ARRAY-ELEMENT-TYPE) so that its behavior on the type :(CLHS NIL) (or any equivalent type) is unspecified. In particular, it need not be the case that (UPGRADED-ARRAY-ELEMENT-TYPE NIL) must be a subtype of (UPGRADED-ARRAY-ELEMENT-TYPE foo) for any type foo.
- Test case:
These arrays are useless, and requiring them prevents an implementation from having certain efficient representations of strings.
- Current practice:
- CLISP and SBCL now implement arrays of element type NIL, but with small differences in the details, such as printing such arrays.
- Cost to Implementors:
- Cost to Users:
- Cost of Non-Adoption:
- NIL arrays imply that :(CLHS STRING) and :(CLHS BASE-STRING) are different types, which prevents an implementation from making the assumption that all strings have the same element type.
- Eliminates silliness, and allows implementations to have more efficient strings.
The "Cost to Implementors" cannot be "None" as there are implementations that do not support arrays with element type NIL.
"Cost to implementors" usually means the cost of adopting the proposed change. Since this proposal would make the definition of such arrays have undefined behavior, how would this cause work for developers of a (non-conforming!) implementation that does not currently support them?
I stand corrected. However, while it is true that making the proposed change would not require work by implementors not supporting the feature, I'd wager that there may still be some issues lurking when the implementors have to "fix" :(CLHS UPGRADED-ARRAY-ELEMENT-TYPE).