Our starting point was that in ObjC at the beginning of the execution, the root meta-class (most of the time NSObject) instantiates all the other meta-classes, that create the class as object for the software.
This is somewhat like how a Smalltalk VM is bootstrapped, but there isn't any real sense in which root classes control how classes are created or loaded in ObjC.
In Swift is it the same? If so, which is the name of the root meta-class?
The root class of a Swift class is a private implementation detail; it's not guaranteed in any way.
If you're just curious about the current implementation, you can look in stdlib/public/runtime/SwiftObject.mm, but again, nothing in there is something that you should rely on as a Swift programmer.
On May 8, 2017, at 6:46 PM, Giacomo Leopizzi <email@example.com> wrote:
Thanks for the fast reply.
On 9 May 2017, at 00:30, John McCall <firstname.lastname@example.org> wrote:
On May 8, 2017, at 6:21 PM, Giacomo Leopizzi via swift-dev <email@example.com> wrote:
I was discussing with a friend about metaclasses in Objective-C. In Obj-C the root meta-class was the NSObject's one.
ObjC does not have a single root class. Most ObjC classes inherit from NSObject, but that is not guaranteed, and in fact there are other common root classes including NSProxy.
When in a swift class you create a subclass of NSObject, the root metaclass should be the same. What happen when you delcare a class without NSObject dependence? There is an hidden root-class? Where can we read more about this topic?
When ObjC interop is enabled, Swift classes that do not inherit from NSObject use a private root class. However, that is a private implementation detail and we don't promise much about it.
Do you have any specific questions?