[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
TYPEP and arrays of (SATISFIES F)
Bob Rorschach has raised the following question: what is the
result of (TYPEP (MAKE-ARRAY 10) '(ARRAY (SATISFIES F) (10)))
supposed to be? Consider these special cases:
(TYPEP (MAKE-ARRAY 10 :ELEMENT-TYPE INTEGER)
'(ARRAY (SATISFIES FIXNUMP) (10)))
(TYPEP (MAKE-ARRAY 10 :ELEMENT-TYPE FIXNUM)
'(ARRAY (SATISFIES FIXNUMP) (10)))
We can easily dismiss the first case, because clearly an array
specialized to hold integers is not necessarily the same as one
specialized to hold fixnums. The second is more difficult. It happens
to be the case that FIXNUM and (SATISFIES FIXNUMP) are equivalent type
specifiers, but in many implementations SUBTYPEP cannot discern this
fact (and indeed is not required to).
When TYPEP sees a plain old SATISFIES specifier, it can just call the
function, but not so when it is the element type of an ARRAY specifier.
One way out (proposed language change) is to define TYPEP to be like
SUBTYPEP, in that it returns two values; if the first value is NIL, the
second value says whether that's a "no" or a "maybe". So for the
first special case above TYPE would return either NIL T or NIL NIL,
depending on the cleverness of the implementation, and for the second
special case would return either NIL NIL or T T.
--Guy