[cfe-dev] Adding namespaces to Objective-C

Adam Nohejl adam+clang at nohejl.name
Fri Nov 12 03:20:25 PST 2010


On 2010/11/12, at 10:57, Jens Ayton wrote:
>> Class conflict is a real problem when you develop plugins. If two plugins developers use the same third party toolkit for example, the host application ends up trying to load each class from this toolkit 2 times, and you don't have any guarantee that they are from the same version of the toolkit.
>> 
>> Unfortunately, I'm not sure this problem can be solved by namespaces,
> 
> Exactly. Namespaces aren’t a fix here. The old Content/SharedFrameworks/ concept might have been, to an extent.

To a small extent. It does not allow you to have two different versions of a framework loaded at the same time, while each plug-in might need a different version (may not be compatible with the most recent version).

> As for the plug-in-specific classes, I always decorate the names along the lines of com_example_whatever_plugin_SomeClass, then use a macro (@compatibility_alias would be good here if it was documented) to access it as SomeClass in code. This is a minor annoyance for classes, but entirely impractical for methods since they aren’t identifiers and aren’t unique.

Yes, but that does not work for third party frameworks used by plug-ins, unless you have access to their source code and can ensure, that they will work correctly after renaming.

In my view the problem with third-party frameworks in plug-ins is a more important problem than clashes at compile time or having to use prefixes. It would be nice to have a unified solution for namespaces AND this as the issues seem to be related, but of course having C++-style namespaces does not imply that there would be no run-time (load-time) clashes.

-- 
Adam





More information about the cfe-dev mailing list