> On 10 Feb 2017, at 13:04 , Oleksandr Zaytsev <olk.zayt...@gmail.com> wrote: > > Hello, > > I'm trying to understand the logic behind The Pharo Object Model. > > Rule 3 states that every class in Pharo has a subclass. I was expecting some > cool loop, like in the case of Metaclass, which is an instance and also a > class of Metaclass class. But ProtoObject, which is the root of an > inheritance hierarchy does not seem to have a superclass (ProtoObject > superclass answers nil, which is not a class). > > Does this mean that Pharo Object Model is inconsistent? Is ProtoObject an > exception of the third rule? > > If you think about it, an inheritance hierarchy can't have a loop, because > otherwise, when looking for a nonexistent method in superclasses, Pharo would > be stuck in that loop. > > So why is there even a loop in instance hierarchy (Metaclass class)? Does it > have a purpose, or is it there only to satisfy the second rule of the Object > Model? Because if the consistency of third rule can not be satisfied, > wouldn't it be better to add two exceptions to the model? > > Please correct me if my understanding or reasoning is wrong. > > Thanks!
Rule 3 says every class has a superclass; it does not say the superclass must be a class. (but it must be an object, as per #1) Hence a superclass of nil isn't inconsistent (as nil is an object), and is a valid way to terminate the inheritance hierarchy. Metaclass class class = Metaclass is necessary not to satisfy #2, but to satisfy both #1 and #2. Rule 2, states that every object is an instance of a class. Classes are also objects according to #1, and as such are instances of a class (Metaclass), so the circular definition when it comes to Metaclass is needed to satisfy both. Cheers, Henry
signature.asc
Description: Message signed with OpenPGP