[Cuis-dev] Behavior of #superclass: message
Juan Vuletich
juan at cuis.st
Fri Nov 28 07:53:01 PST 2025
In addition to Martin's very good answer, I'll add a Cuis specific detail.
Regular classes are created by sending a message to the
superclass-to-be. The problem is how to create subclasses of nil. In
Cuis this is done in a rather hacky way:
ProtoObject subclass: #ProtoObject
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Kernel-Objects'.
ProtoObject superclass: nil
So first the class is created as subclass of something else and then the
superclass is set to nil. However, ProtoObject class superclass is
Class. And this trick shows in ClassDescription >> #definition. The
reason for not simply sending
#subclass:instanceVariableNames:classVariableNames:poolDictionaries:category:
to nil (as it ised to be before we implemented this) is that a a missing
class in a file-in would result in classes with unexpected nil
superclass, instead of an error message.
I guess this all could be done in a clearer way. And this kind of hack
is the only reason for #superclass:
HTH,
On 2025-11-27 5:42 PM, Facundo Javier Gelatti via Cuis-dev wrote:
> Hi!
>
> I've noticed that the #superclass: message does not affect the
> superclass of the (meta)class of the receiver. For example:
>
> Object subclass: #A instanceVariableNames: '' classVariableNames: ''
> poolDictionaries: ''.
> Object subclass: #B instanceVariableNames: '' classVariableNames: ''
> poolDictionaries: ''.
>
> B superclass. " => Object "
> B class superclass. " => Object class "
>
> B superclass: A.
>
> B superclass. " => A "
> B class superclass. " => Object class (not A class)"
>
> The Class>>#superclass: method has a comment that says "Not to be used
> lightly!", so I'm not sure if this is in fact the expected behavior
> (but at least I was surprised by it).
>
> Cheers!
> Facu
>
--
Juan Vuletich
www.cuis.st
github.com/jvuletich
researchgate.net/profile/Juan-Vuletich
independent.academia.edu/JuanVuletich
patents.justia.com/inventor/juan-manuel-vuletich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20251128/99113826/attachment.htm>
More information about the Cuis-dev
mailing list