From: Peter Suk Date: 2005-04-24T00:52:20+09:00 Subject: Re: Truth, Void, Smalltalk, Lisp, and Ruby (was: Re: Ilias is Crazy -- a plea) On Apr 23, 2005, at 9:24 AM, Christian Neukirchen wrote: > Peter Suk writes: > >> On Apr 23, 2005, at 5:58 AM, Christian Neukirchen wrote: >> >>> No. Object doesn't have a superclass, as much as Lisp's T doesnt have >>> a superclass. It is not nil, even if ***** may think that. >> >> In the Smalltalk world, "not having a * in slot x" and the * being nil >> are equivalent. So if the thing in the superclass slot of Object's >> class is nil, Object's superclass is nil. Also note that Object (and >> other classes in most Smalltalks, see below) inherit everything they >> possibly can from nil -- which is nada. (And remember, you >don't< >> inherit from the metaclass of your superclass.) > > I'm sure this is not correct for Ruby. > > For Smalltalk, I'm not very deep into it, but (Squeak 3.7): > > Object superclass => ProtoObject > ProtoObject superclass => nil Ah, this is Squeak's "Burn the diskpacks!" philosophy at work. "Object superclass" in VisualWorks yields nil. Also in ObjectStudio. In Smalltalk Agents, Object is actually a subclass of Collection, which makes sense. (In Smalltalk all objects partially duck-type as a collection. They all understand at: and at:put: .) > However: > > nil class => UndefinedObject > UndefinedObject superclass => Object > > ProtoObject *does not inherit from nil*, but from nothing, > *represented by nil*. Behavior explicitly checks if superclass is > nil, e.g. in Behavior#allSuperclasses. Ahead of you here. Remember I say above: >> (And remember, you >don't< >> inherit from the metaclass of your superclass.) UndefinedObject is effectively the metaclass of the superclass of Object. And you don't inherit from the metaclass of your superclass. You can think of nil as the only structure-less Behavior in Smalltalk. How you term it is arbitrary, since what it does is what really matters. > Most lisps actually compile their functions and don't run them from > the AST, but that would be possible in theory at least. One can think of this as an implementation detail. Most commercial Smalltalks also are compiled down to machine language. My lisper coworker told me that Symbolics Lisp could switch between these two modes, depending on what it could get away with in any given situation. >> Not all Smalltalks have a ProtoObject. (Is that VisualAge?) Also, >> Proxy objects are often defined that have nil as a superclass in >> different Smalltalks. (Another amusing anecdote: the Refactoring >> Browser guys, John Brant and Don Roberts, do as a part of their demo, >> the renaming of the root class Object (and all references) in the >> running image. After only a few minutes, we find we are doing >> Thingy-Oriented programming.) > > I only have Squeak handy, can't check really. I bet if you go back to an early enough implementation of Squeak, you will find Object at the root hierarchy, since Squeak's image started using the Smalltalk-80 image. Also, my project at work in VisualWorks has proxies with superclass of nil. ObjectStudio definitely does. It's a fairly standard thing, since it makes implementing proxies easier. > And: You can set the > superclass to be nil, but that makes certain methods not look at the > superclass, not look at nil. That's really an implementation detail -- people doing conditional logic where polymorphism would also do. I just inspected UndefinedObject in Squeak 3.7 and used the inspector window to set its superclass to Class. Now we can reimplement methods like allSuperclasses so that they are polymorphic. (Well, you have to change a bunch of other assumptions in the system too. Browsers will now throw exceptions on certain operations. But things still *kinda* work. :) I know there is a doesNotUndertand equivalent, so Ruby has forwarding proxies. Is there an equivalent of become: ? --Peter -- There's neither heaven nor hell, save what we grant ourselves. There's neither fairness nor justice, save what we grant each other.