help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] Re: [patch] Enhance to kernel/Behavior.st


From: Paolo Bonzini
Subject: [Help-smalltalk] Re: [patch] Enhance to kernel/Behavior.st
Date: Tue, 27 Oct 2009 09:16:07 +0100
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20091014 Fedora/3.0-2.8.b4.fc11 Lightning/1.0pre Thunderbird/3.0b4

On 10/27/2009 04:40 AM, Lee Duhem wrote:
Subclasses of nil? I didn't understand what this means,  can you explain further
or point to some documents?

While 99% of the classes are subclasses of Object, it is also possible to create classes that do not inherit from anything (or equivalently, whose subclass is nil). In this case, the metaclass will be a subclass of Class; so I used in my example "Class allSubclassesDo:" to get the metaclasses (which provide class-side methods), and go to the classes (which provide the instance side) by sending #asClass.

There is a small part in the tutorial on this topic; alternatively, you may see if you find a presentation called "The Behavior of Behavior".

By the way, the reason why I didn't like #allSuperclasses is the following. The #superclass and #subclasses methods return the classes that are "adjacent" (one level up or one level down) in the hierarchy. Prefixing "all" gives also the indirect superclasses/subclasses. #superclasses then would be a method that returns an array of direct superclasses (which would have a single element, since Smalltalk only has single inheritance).

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]