torriem at chem.byu.edu
Tue Feb 13 16:27:22 MST 2007
On Tue, 2007-02-13 at 16:19 -0700, Levi Pearson wrote:
> I'm not sure what you mean when you say that Smalltalk doesn't have a
> concept of a class and a class instance.
Right. That was my point. In Java a class is a somewhat abstract thing
that doesn't quite exist as a first-class object.
> Smalltalk actually has a
> very well-developed concept of classes, though classes are indeed
> objects as well. Every object has a class, which is an object of its
> own metaclass. Metaclasses are also objects, and have a class as
> well, etc. Thus, while everything is still an object, there are also
> classes and instances. Here's a page that describes it, with some
> diagrams that really help make it comprehensible:
> It's Self, which is a derivative of Smalltalk, that eschews the
> class/instance distinction and instead uses a prototype-based form of
> While Java has the concept of classes, if I recall correctly it does
> not treat them as fully-fledged objects, and I certainly don't recall
> a concept of metaclass in Java.
Correct. So a Java class is not really an object (static classes are
kind of an exception to that). Hence my statement about shoe-horning
the Smalltalk-style object system into Java's
In Python, because a "class" is really must an object (or a metaclass),
I can get a reference to it, and add methods or what have you to it, and
have all the existing (I think) and subsequent instances of said class
gain the new functionality on the fly. It's very useful, especially
when you want to extend a mechanism that's already been implemented in
one unit and used by another, without have to do a lot of inheritance.
Sounds messy, but there are times when this capability just makes very
(Is this sort of what aspect-oriented programming is all about?)
> PLUG: http://plug.org, #utah on irc.freenode.net
> Unsubscribe: http://plug.org/mailman/options/plug
> Don't fear the penguin.
More information about the PLUG