From: Christian Neukirchen Date: 2005-04-23T23:24:04+09:00 Subject: Re: Truth, Void, Smalltalk, Lisp, and Ruby (was: Re: Ilias is Crazy -- a plea) 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 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. The actual difference is in Smalltalk not as important, though, as you test with ifNil and therefore can ducktype other objects to nil, which is not possible in Ruby (there is no #to_b). >> Also, CLOS doesn't have "Object", it uses T for that. > > My bad. I was assuming from the conversation with my Lisper coworker. > I'll have to download a Common Lisp. Haven't played with one since > college. Apparently, there's a lot of neat stuff in there. My lisper > coworker also noted that the way Ruby defines methods seems to be > similar to the way Lisp does it. Lisp is automatically its own AST. > Under the covers in Ruby, the AST subtree of the method def is sent to > the class. Most lisps actually compile their functions and don't run them from the AST, but that would be possible in theory at least. >>> Hence Lisp springs from "Truth." While Smalltalk and Ruby spring from >>> the "void" or "nothingness." There is an eastern/western religion >>> thing in there somewhere. >> >> Well, that's not entirely true... IIRC, Lisp's NIL is an own rootclass >> too (or something different, as you can't inherit from it..., but it >> is not derived from T), so you have T and NIL as "rootclasses", >> whereas Smalltalk and Ruby have only one, ProtoObject and Object >> respectively. > > 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. And: You can set the superclass to be nil, but that makes certain methods not look at the superclass, not look at nil. > --Peter -- Christian Neukirchen http://chneukirchen.org