swarm-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [swarm-hackers] Naming conventions


From: Scott Christley
Subject: Re: [swarm-hackers] Naming conventions
Date: Wed, 18 Nov 2009 10:30:14 -0800


On Nov 16, 2009, at 10:47 PM, Bill Northcott wrote:


As I understand the Objective-C class structure, the root object as created in the runtime is Object and NSObject is a subclass of Object.

Not exactly, both Object and NSObject are root classes. They are independent of each other though similar.


As I understood the old version of Swarm it separately subclassed Object, thus avoiding adopting NSObject protocols.

Am I correct to understand that your latest code creates the Swarm classes as subclasses of NSObject? Is this what the openstep build flag does?

Yes, if you enable openstep then the Swarm classes inherit from the NSObject root class. This is necessary because the Apple objc runtime expects classes to implement certain methods, methods that NSObject provides. Now it is possible that we could enhance Object to have this capability or create our own root class, but why? Also it seems some of these methods deal with implementation specific issues, like - methodSignatureForSelector: so it is not immediately obvious what the correct implementation would be for own root class.


Do the resulting Swarm objects understand both 'new' and 'create' instantiation methods? (I understand that mixing them is a quick way to a crash.) Would this mean that they are 'first class' Cocoa objects, but that one should never invoke a Cocoa method on a Swarm object even though introspection would show it as available?

I think pretty much just the instantiation methods are an issue, so 'new' shouldn't be used for Swarm objects, but other methods should be just fine. So yes the idea is in many ways that Swarm objects be 'first class' Cocoa objects. I think though that it might be relatively straightforward to redirect the Cocoa methods 'alloc', 'new', etc to call the Swarm instantiation methods. The other possibility is to have the Cocoa methods throw exceptions and point the user to 'create', actually that was the error that Nima got when he mixed the two.

Scott





reply via email to

[Prev in Thread] Current Thread [Next in Thread]