[cfe-dev] Adding namespaces to Objective-C
Chris Lattner
clattner at apple.com
Tue Nov 9 16:51:37 PST 2010
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.
-Chris
More information about the cfe-dev
mailing list