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: > http://www.ifi.unizh.ch/richter/Classes/oose2/05_Metaclasses/02_smalltalk/02_metaclasses_smalltalk.html > > It's Self, which is a derivative of Smalltalk, that eschews the > class/instance distinction and instead uses a prototype-based form of > inheritance. This is similar to how Javascript does things. > > 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 not-quite-so-object-oriented paradigm. 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 elegant. (Is this sort of what aspect-oriented programming is all about?) Michael > > --Levi > > /* > PLUG: http://plug.org, #utah on irc.freenode.net > Unsubscribe: http://plug.org/mailman/options/plug > Don't fear the penguin. > */ > /* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
