From: Candy Pang
Subject: CLOS hierarchy
Date: 
Message-ID: <6v3fgq$8g0$1@scapa.cs.ualberta.ca>
Hi,

I have to put this in front: I don't know CLOS at all.
However, I am working on some Object-oriented language research.

I just wonder can someone nice teach me how to find the
object hierarchy of CLOS?
I want all defined classes for the environment, their relationship,
and all methods defined for each class.

I tried to look this up from the Web.  I have gotten some sourse
code, but it seems to me that the CLOS hierarchy is really small.
I thought I have gottent the wrong stuff.

Anyway, any help on this will be highly appreciated.

Candy Pang 8)

MSc in Computing Science of University of Alberta, Canada.

P.S. In my server the newsgroup "comp.lang.clos" is empty.  I am not
sure whether it is active.  Therefore, I posted this thing here.
--

From: Howard R. Stearns
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <361A3DCA.61A8DB84@elwood.com>
Candy Pang wrote:
> 
> Hi,
> 
> I have to put this in front: I don't know CLOS at all.
> However, I am working on some Object-oriented language research.
> 
> I just wonder can someone nice teach me how to find the
> object hierarchy of CLOS?
> I want all defined classes for the environment, their relationship,
> and all methods defined for each class.
> 
> I tried to look this up from the Web.  I have gotten some sourse
> code, but it seems to me that the CLOS hierarchy is really small.
> I thought I have gottent the wrong stuff.
> 
> Anyway, any help on this will be highly appreciated.
> 
> Candy Pang 8)
> 
> MSc in Computing Science of University of Alberta, Canada.
> 
> P.S. In my server the newsgroup "comp.lang.clos" is empty.  I am not
> sure whether it is active.  Therefore, I posted this thing here.
> --

(comp.lang.clos is active, but low volume)

There is code to do this in Chapter 2 of "The Art of the MetaObject
Protocol." (AMOP).

Although the code is not very long, I haven't included it because:

1. I want you to read the book.  It's a must for anyone doing research
on OO, especially, as your question implies, anyone intrested in
introspective reflection.

2. The code might not do what you expect:
  1. CLOS has multiple inheritance, so how should the "hierarchy" be
displayed?         It's a network.  The AMOP gives code to display the
whole class definition,    
     as Lisp source code, including the direct superclasses.
  2. CLOS has multi-methods, where methods can be specialized on any
required 
     argument, not just the first.  Thus a method might reasonably be
associated 
     with as many different classes as there are required arguments for
the 
     method. The AMOP gives code to print Lisp source code information
about all 
     the methods specialized for a given class.
  3. There are a LOT of functions in Common Lisp, any of which could be 
     implemented as methods on generic functions.  Printing out the Lisp
source 
     code information for all classes and all methods in a given Lisp 
     implementatin could take a very long time.

References for the AMOP and related work, including a book which gives
comparisons between CLOS and Smalltalk, C++, etc., is at
http://www.elwood.com/alu/table/references.htm#mop
From: Rainer Joswig
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <joswig-0610981826260001@pbg3.lavielle.com>
In article <·················@elwood.com>, "Howard R. Stearns"
<······@elwood.com> wrote:

>   3. There are a LOT of functions in Common Lisp, any of which could be 
>      implemented as methods on generic functions.  Printing out the Lisp
> source 
>      code information for all classes and all methods in a given Lisp 
>      implementatin could take a very long time.

Hmm, the Lisp environment on my Mac (Macintosh Common Lisp) has 1535
classes and around 9500 messages (including loaded software).
My Lisp machine has much more when you count Flavors+New Flavors+CLOS.

Maybe the question was what classes and methods pure ANSI CL
has?

-- 
http://www.lavielle.com/~joswig
From: Sunil Mishra
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <efyemslh69f.fsf@aidan.cc.gatech.edu>
······@lavielle.com (Rainer Joswig) writes:

> In article <·················@elwood.com>, "Howard R. Stearns"
> <······@elwood.com> wrote:
> 
> >   3. There are a LOT of functions in Common Lisp, any of which could be 
> >      implemented as methods on generic functions.  Printing out the Lisp
> > source 
> >      code information for all classes and all methods in a given Lisp 
> >      implementatin could take a very long time.
> 
> Hmm, the Lisp environment on my Mac (Macintosh Common Lisp) has 1535
> classes and around 9500 messages (including loaded software).
> My Lisp machine has much more when you count Flavors+New Flavors+CLOS.
> 
> Maybe the question was what classes and methods pure ANSI CL
> has?

Well, if you take pure ANSI CL, then there are many classes that might be
required. Examples are condition objects and perhaps streams. I had
responded to the original query a while back. To me at least it appears
that the CL standard leaves enough flexibility that it is open to
interpretation how many classes are *required* by CL.

If the question is restricted to CLOS though, that is, how many classes do
you need to have a running CLOS implementation, the number is tiny. At
least based on the CLOSETTE implementation in AMOP. In fact, I don't see a
single required *class*. There are various metaclasses that are required
though, such as standard-class and builtin-class, without which CLOS could
not exist within CL.

I would not be surprised if I have something wrong above, so if anyone
cares to throw in some wisdom that would be great.

Sunil
From: Tim Bradshaw
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <ey3u31hbhpm.fsf@wiay.aiai.ed.ac.uk>
* Sunil Mishra wrote:

> Well, if you take pure ANSI CL, then there are many classes that might be
> required. Examples are condition objects and perhaps streams. I had
> responded to the original query a while back. To me at least it appears
> that the CL standard leaves enough flexibility that it is open to
> interpretation how many classes are *required* by CL.

Remember that all the basic types of CL have corresponding classes.
If I can count correctly that is 91 classes.  Most of these classes
are instances of BUILT-IN-CLASS, and can't be subclassed using
DEFCLASS and so on, but you *can* define methods on them, so you don't
need all these weird wrapper classes that languages with a
less-integrated object system like C++ or Java end up with.

--tim
From: Sunil Mishra
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <efyd884s715.fsf@peachtree.cc.gatech.edu>
Tim Bradshaw <···@aiai.ed.ac.uk> writes:

> Remember that all the basic types of CL have corresponding classes.
> If I can count correctly that is 91 classes.  Most of these classes
> are instances of BUILT-IN-CLASS, and can't be subclassed using
> DEFCLASS and so on, but you *can* define methods on them, so you don't
> need all these weird wrapper classes that languages with a
> less-integrated object system like C++ or Java end up with.
> 
> --tim

Well, I hadn't ever thought of them as classes, so I had left them out of
consideration in my post.

Sunil
From: Tim Bradshaw
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <ey3r9wkqqy0.fsf@todday.aiai.ed.ac.uk>
* Sunil Mishra wrote:

[CL types as classes]

> Well, I hadn't ever thought of them as classes, so I had left them out of
> consideration in my post.


I think it's quite important not to leave them out in general,
especially since they do provide a lot of the functionality that
people claim CLOS is missing (`why is there no standard linked list
class?'), and the fact that you can define methods on all CL types is a
significant advantage over many other object systems.

--tim
From: Kent M Pitman
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <sfwd883nbzf.fsf@world.std.com>
[comp.lang.lisp only. 
 http://world.std.com/~pitman/pfaq/cross-posting.html]

Tim Bradshaw <···@aiai.ed.ac.uk> writes:

> ... the fact that you can define methods on all CL types is a
> significant advantage over many other object systems.

you can?  i don't think so.  maybe you mean on all CL classes.

you can't define a method on a type defined by DEFTYPE.
you can't define a method on a "system type", like BOOLEAN.

you can define them on system classes like INTEGER.
From: Tim Bradshaw
Subject: Re: CLOS hierarchy
Date: 
Message-ID: <ey3pvc3qob0.fsf@todday.aiai.ed.ac.uk>
* Kent M Pitman wrote:


> you can?  i don't think so.  maybe you mean on all CL classes.

That's what I meant, sorry.  I guess to be precise I meant you can
define methods on BUILT-IN-CLASSes.  But that is still a significant
win, over Java and its wrapper-classes for numbers for instance (and
don't you have to subclass them before you can define methods on them
even, because you can only define methods in the class definition?  Ick!)

--tim