Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!cornellcs!travelers.mail.cornell.edu!news.kei.com!news.mathworks.com!newsfeed.internetmci.com!news.sprintlink.net!mv!usenet
From: rapp@lmr.com (L. M. Rappaport)
Subject: Re: 'new' method for Object?
Message-ID: <DEwGxL.Mpu@mv.mv.com>
Nntp-Posting-Host: lmr.com
Sender: usenet@mv.mv.com (System Administrator)
Organization: MV Communications, Inc.
Date: Thu, 14 Sep 1995 17:43:24 GMT
References: <42ms5m$fjr@bronze.coil.com> <42oq59$cks_001@netcom.com> <42vs32$40i@nuhou.aloha.net> <DEq3Hv.Hq5@cunews.carleton.ca> <437jg6$u6t@watnews1.watson.ibm.com>
X-Newsreader: Forte Free Agent 1.0.82
Lines: 134

David,

  That was the best explanation I've ever read.  We are all indebted
to you.  A few questions:

>First off, most of what you know about classes is a lie. Browsers
>routinely lie. Classes do NOT have 'instance methods' and 'class
>methods'. Here is the truth:

You mean what one has learned about classes from browsers, right?

>Everything is an object. All classes are just instances of some
>object or another. There is only one kind of method, not two.

I'm not sure I understand this.  I always thought that what
differentiates a class method from an instance method was more of a
scoping issue.  An instance method operates on data local to the
object whereas a class method operates on data accessible to the
class, and, therefore, accessible to all instances of that class.
Perhaps what you mean is that a class method to a class is the same as
an instance method to an object in that both of them are objects?

>Instances that are classes have an extended hierarchy:

>   Object
>      Behavior
>   _____ Class _________ 
>            Object class
>               Magnitude class
>                  Number class
>                     Float class
>                     Integer class
>                  Date class

Seems like the problem here is that the browser lies!  :)  What exists
above the Class line are not the same entities as what show below it,
correct?

>It is the classes above the line that make classes act like classes.

This is confusing, as it seems like they should then be metaclasses,
but as I understand it, metaclasses can only exist on a one to one
basis with the underlying class, so they cannot inherit from one
another.


>Taking this one step more:  

>   aString <= String <= String class

>This means that class String is an instance of a class named 'String
>class'. You've probably noted this already if you ever evaluated
>one of the expressions:

This is where I think my understanding has broken down:  This extra
class 'String Class' whose sole instantion is the 'String' class.
This is what I have always thought of (apparently incorrectly) as the
string metaclass.  I thought that the metaclass was a template for the
generation of one and only one class, but in your explanation

>   aString <= String <= String class <= Metaclass

There is that one extra class "String class".  I'm not questioning
your accuracy, it's obviously my understanding that is incorrect, as
is also evidenced by the fact that both class and metaclass are
children of behavior.

>So what is Metaclass (spelled MetaClass on some systems)? It is
>another subclass of Behavior:

>   Object
>      Behavior
>         Class
>         Metaclass

Yes, but now metaclass has as it's purpose to instantiate a class
intermediate to class... I am missing something.  

>   String class class class class class

>   aString <= String <= String class <= Metaclass <= Metaclass class 
>      <= Metaclass <= Metaclass class <= Metaclass ...

Doesn't this stop at Metaclass class by definition?  (There can only
be one instance of Metaclass Class and it has no parent?)

>There are TWO anomolies here:

>(1) That class 'Object class' inherits from class 'Class'. (Try
>reading that aloud!)

>(2) That Class Metaclass is an instance of an instance of itself!

>(Sometimes I add a third involving inheriting from nil, but that
>is beyond the scope of a short note.)

>These two anomolies allow Smalltalk to have a clean, elegant, and
>(after some contemplation) understandable self-definitional
>facility in which everything is an object and all objects are
>instances of classes (including classes themselves).

Yes, other than that it all has to end somewhere!!!

>So, now the Big Lie (George Bosworth calls it an Artful Deception)
>should be clear. Classes do not have two kinds of methods. They
>have just one kind of method, and the methods are for the INSTANCES
>of that class:

Again, don't you think that it is more a question of the description
of scoping?  Sure a class method is the same as an instance method, we
just call them "class methods" to denote that they operate on data
accessible to all members of a class. 

>Metaclasses (instances of class Metaclass) exist so that (among
>other reasons) there is somewhere to put the methods of its
>instance. There is just one such instance per class, since each
>class has the need to hold just one set of methods.

AHHHH!  Ok, since by your definition an instance might not have
methods, THAT is why it is necessary to have an String Class class
which instantiates the class (which is also an object) String.  String
class cannot instantiate anything which has methods of it's own, the
instantiated object must use the methods of the String class which
gets them from the String Class class.  Have I finally got it right?

Well, YOU asked for questions. :)

Thanks,

Larry
--



