In article <··········@sci3.sri.ucl.ac.be> ····@tcp.co.uk (Manuel Kolp) writes:
>Can an object be an instance of two or more classes in CLOS?
I'm not certain what you are asking, so I'll try to answer several
possible underlying questions.
It can be a *direct* instance of only one class; MAKE-INSTANCE takes
only a single classname as an argument. That class can have
multiple ancestors of course (inheritance) and even multiple direct
parents (multiple inheritance). The object will be considered an
instance of all of those classes.
See the CLOS section of <http://www.apl.jhu.edu/~hall/lisp.html>
for summarized info on CLOS syntax and common "gotchas".
- Marty
(proclaim '(inline skates))
From: Ken Tilton
Subject: Re: instance of two or more classes in CLOS
Date:
Message-ID: <31D7D6CE.50BC@bway.net>
Manuel Kolp wrote:
>
> Can an object be an instance of two or more classes in CLOS?
>
> Manuel Kolp
> University of Louvain
> ····@qant.ucl.ac.be
No, unless you mean "Does CLOS allow multiple-inheritance?", in which
case Yes.
An object is created via:
(make-instance 'classX)
The *class* may inherit from two or more classes:
(defclass classX (classY classZ) ())
...but the object will be an instance of one class, classX.
Now, yes, *I* think of the object as being of two classes (Y and Z), but
then one could argue even in a single inheritance model that an object
is an instance of each of its superclasses.
That is a dangerous way of thinking, however. Objects are nice, but just
as sometimes a little assembler background helps to understand what is
going on in a high-level language, one needs sometimes in OO to
understand how the OO model works internally.
Cheers,
Ken