member types and array-element-type?
>> I also have problems with this:
>>
>> (typep 'single-float '(member single-float (signed-byte 16)))
>> => T
>>
>> (typep '(signed-byte 16) '(member single-float (signed-byte 16)))
>> => NIL
>>
>> So you can't really tell if something is of that type.
Arthur> I think you're confusing MEMBER and OR: MEMBER combines objects
Arthur> (using EQL to check for membership), OR combines arbitrary type
Arthur> specifiers.
Arthur> So:
I don't think so, but my examples my have been confusing.
[examples snipped]
Arthur> At least, that's how I understand the standard.
I think I'm not being clear enough in what I want to know.
Here's the original function:
(defun foo (x)
(declare (type (or (array single-float (*))
(array double-float (*))
(array (signed-byte 16) (*)))
x))
(array-element-type x))
Assume you have the specialized arrays given above. For a
sufficiently smart compiler, if you ask it what the return type of the
function FOO is, what would it say?
This function can return 1 of three values:
o The symbol 'single-float
o The symbol 'double-float
o The LIST '(signed-byte 16)
What is the correct description of this type? Is it
(MEMBER SINGLE-FLOAT DOUBLE-FLOAT (SIGNED-BYTE 16))?
It can't be (or single-float double-float (signed-byte 16)) as you
seem to suggest because FOO DOES NOT return a number. It
returns the a SYMBOL or a LIST.
Then (typep 'single-float (member single-float double-float
(signed-byte 16))) return T, as expected. But typep with
'(signed-byte 16) is NIL because it's not eql to any of the types
listed in the member.
Ray