[Cuis-dev] nil subclasses (Re: clever or silly idea?)

Hernán Wilkinson hernan.wilkinson at 10pines.com
Wed Jun 12 07:06:08 PDT 2024


one of the goals of ProtoObject is not to sublass nil


*Hernán WilkinsonAgile Software Development, Teaching & Coaching*
*Phone: +54-011*-4893-2057
*Twitter: @HernanWilkinson*
*site: http://www.10Pines.com <http://www.10pines.com/>*
Address: Alem 896, Floor 6, Buenos Aires, Argentina


On Wed, 12 Jun 2024 at 10:23 Juan Vuletich via Cuis-dev <
cuis-dev at lists.cuis.st> wrote:

> Hi Folks,
>
> On 6/11/2024 9:45 PM, Andres Valloud via Cuis-dev wrote:
> > Make a subclass of nil called Parrot.  Implement only
> >
> >     doesNotUnderstand: aMessage
> >
> >         ^self
> >
> > and then evaluate the following.
> >
> >     Parrot new ifTrue: [#haha] ifFalse: [#hehe]
> >
> > Explain the behavior you see.
> >
> > Side comments...
> >
> > 1.  It should not be that hard to create a new subclass of nil,
> > substituting in ProtoObject when it was not requested is unhelpful.
> >
> > 2.  I could not redefine an existing class to have a superclass of nil
> > because the process sends removeObsoleteSubclass: to the superclass of
> > the class in question, which in this case is nil.  Juan, this looks
> > like new code you wrote recently, you may want to review what happened
> > here.
>
> 1. That's a good question. Is it helping or not? Shouldn't a subclass of
> ProtoObject be used instead? Not really sure. I think I've never seen a
> case where having ProtoObject as superclass is more a problem that a
> convenience.
>
> 2. Fixing that right now. Done. Fix at GitHub.
>
> 3. This is another issue. If you see the definition of ProtoObject in
> the browser, or the comment at UndefinedObject >>
> #subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:
>
> , the recommended way to create the class is to make it subclass of
> Undefined object, and then do `Parrot superclass: nil`. This is
> disturbing. Parrot will have superclass == nil, but will be included in
> the subclasses array of ProtoObject. The superclass / subclass invariant
> is broken. This code has been there for 25 years, and I wouldn't modify
> it lightly. Moreover, if you evaluate the suggested class definition, it
> will appear repeated times, like ProtoObject subclasses = #(Object
> MessageCatcher BreakingMethodWrapper Parrot Parrot Parrot Parrot) . So
> something has to be done.
>
> I guess the only subclass of nil created in 25 years is ProtoObject
> itself...
>
> --
> Juan Vuletich
> cuis.st
> github.com/jvuletich
> researchgate.net/profile/Juan-Vuletich
> independent.academia.edu/JuanVuletich
> patents.justia.com/inventor/juan-manuel-vuletich
> linkedin.com/in/juan-vuletich-75611b3
> twitter.com/JuanVuletich
>
> --
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240612/d1cf78ab/attachment.htm>


More information about the Cuis-dev mailing list