[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Chap 3 question: Class of allocated instances.
- To: Jon L White <firstname.lastname@example.org>
- Subject: Chap 3 question: Class of allocated instances.
- From: David A. Moon <Moon@STONY-BROOK.SCRC.Symbolics.COM>
- Date: Wed, 12 Apr 89 11:13 EDT
- Cc: email@example.com
- In-reply-to: <8904120631.AA19866@bhopal>
- Reply-to: Common-Lisp-Object-System-mailer@SAIL.Stanford.EDU
Date: Tue, 11 Apr 89 23:31:52 PDT
From: Jon L White <firstname.lastname@example.org>
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