On 10 Aug 2010, at 10:59, Frank Heckenbach wrote:
- All classes have a common ancestor.
Most classes have a common ancestor, but not all of them do. There are at least two root classes in the Cocoa framework: NSObject (the most commonly used one) and NSProxy (mostly used for language bridges and for remote message passing).
You can define as many root classes as you want, with the only restriction that they have to conform to the NSObject protocol (a protocol is similar to an interface in Java/Delphi-style Pascal -- and yes, protocols and classes can have the same name).
(That's not a new thing, we've had this discussion WRT Pascal object models.) Many Objective-C proponents seem to tout this as a big advantage, I see it as a restriction. E.g., that an "untyped" object pointer exists and is still useful (in contrast to a real untyped pointer).
There is an "untyped object pointer" in Objective-C, but it's unrelated to any root class. This type is called "id", and it is actually more like universally typed: without type casting, you can a) assign an id-typed variable to any variable of another class type (or of the id type), and vice versa b) send any message to it without type casting it to a particular class type (with of course the possibility of getting an exception at run time if the actual type does not respond to that message's selector)
However, the original question seems to be more about binary compatibility to existing Objective-C code, which would probably not be achieved this way.
GCC (and LLVM's Clang) support Objective-C++, which allows mixing Objective-C and C++ in the same source file. You would have to translate Objective-Pascal to Objective-C, not to C++.
Jonas