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

Chap 3 question: Class of allocated instances.

    Date: Tue, 11 Apr 89 23:31:52 PDT
    From: Jon L White <jonl@lucid.com>

    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?  

Flavors has such a feature, which is used quite a bit.

		     Is it still useful if the constraint is added that

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

The Flavors feature satisfies this constraint.

    Without some such constraint, it might be possible for 

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

    to be false.    

I don't really see any reason for CLOS to prohibit users from creating
classes or metaclasses that behave this way, violating that constraint.
That might not be good style, and it might be the case that those classes
will not work with some programs.  But I don't see any reason to forbid
it outright.