[cfe-dev] Adding namespaces to Objective-C
mailing-lists.jens at ayton.se
Thu Nov 11 19:12:21 CST 2010
On Nov 9, 2010, at 22:54, Owen Shepherd wrote:
> The hardest aspect seems to be namespacing of selectors; it seems to be an issue which I haven't really seen affecting other languages, and seems a rather difficult one to solve elegantly, though I must ask: Is it a major issue in practice? I haven't found it to be, and haven't found other people claiming it to be either, though I don't claim that it doesn't exist.
Yes. Selector conflicts are more subtle and therefore nastier than class name conflicts, and far more onerous to handle using prefixes. Given the choice, I’d much rather have namespaces for selectors than for classes.
(An advantage of only namespacing selectors is that you could use the most elegant namespace separator I’ve come across: a space. [object namespace method] is unambiguous, as long as you don’t also allow [namespace Class method]. I don’t expect this idea to win the day, though.)
As a practical example of a selector conflict, I once had an app crash on one user’s machine because it had a convenience method -[NSDictionary setDouble:forKey:], and an input manager hack defined a -setDouble:forKey: with conflicting semantics. I’ve heard of people being bitten by conflicts with methods introduced in superclasses in system updates, too.
On Nov 10, 2010, at 00:50, Owen Shepherd wrote:
> Namespaces are a property of types, of which objects are just one form
Namespaces are a property of names, of which types are just one form.
On Nov 11, 2010, at 19:41, jahanian wrote:
> 1. Somehow c has survived 30+ years not needing namespaces. I am told that it is not on the table yet.
C (per se) doesn’t have dynamic name lookups.
More information about the cfe-dev