[Cuis-dev] Behavior of #superclass: message

Martin McClure martin at hand2mouse.com
Thu Nov 27 13:15:49 PST 2025


Hi Facu,

I haven't looked at the code, but perhaps #superclass: is a low-level 
method that just does that one change.

A higher-level facility might want to change the superclass in both the 
class and the metaclass, but it can't do that in one method because of 
encapsulation -- one method can't change the superclass instance 
variable in two different objects. So what message would it send to each 
of the class and the superclass? One logical selector to choose for that 
would be #superclass:.

Regards,

-Martin

On 11/27/25 12: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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20251127/539db608/attachment.htm>


More information about the Cuis-dev mailing list