[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Chap 3 question: Class of allocated instances.



I'm wondering why one can't count on the following being true:

   (eq (find-class 'foo)  (class-of (allocate-instance 'foo)))

Presumably, if a programmer defined a method on 'allocate-instance'
he could have it return any old sort of widget (rather than a "foo").  
Is this useful?  Is it still useful if the constraint is added that

   (subtype (class-of (allocate-instance 'foo)) 'foo)

Without some such constraint, it might be possible for 

    (typep (allocate-instance 'foo) 'foo)

to be false.    It was similar such problems that led to the
"cleanup" proposal ARRAY-TYPE-ELEMENT-TYPE-SEMANTICS -- that often
one could have the following turn out false:

    (typep (make-array <n> :element-type '(array <some-type>))
           '(array <some-type>))


-- JonL --