[cfe-dev] Adding namespaces to Objective-C

Jean-Daniel Dupas devlists at shadowlab.org
Wed Nov 10 00:31:33 PST 2010


Le 10 nov. 2010 à 01:51, Chris Lattner a écrit :

> 
> On Nov 9, 2010, at 3:50 PM, Owen Shepherd wrote:
> 
>>> Would declare the Object class in the global namespace as NSObject, and in the Foundation namespace as Foundation!Object.  The runtime functions for iterating over classes would only see the version in the global namespace and a set of new functions would provide introspection.
>> 
>> The :: syntax is unambiguous, familiar, and common with that of C++. I see no reason to be distinct for the sake of it. As for short aliases, I see no reason why one could not do
>> 
>> namespace Foundation { @interface Object ... }
>> using NSObject = Foundation::Object;
>> 
>> Longer? Slightly. However, it provides the option to avoid polluting the global namespace in the general case, something which is always useful.
> 
> FWIW, :: is not a token in ObjC.

No, but it may be used in selector.

@selector(foo::::) is a valid selector. So, if namespace applies to selector too, you will have to figure a way to define qualified selector name.



-- Jean-Daniel








More information about the cfe-dev mailing list