Objective-C Namespaces

Originator:pburleson
Number:rdar://7025435 Date Originated:7/1/2009
Status:Duplicate/2821039 Resolved:
Product:Developer tools Product Version:
Classification:Enhancement Reproducible:Not Applicable
 
01-Jul-2009 05:20 PM Patrick Burleson:
Summary: 
The Objective-C runtime should support namespaces to allow for the same named class to exist without collision. In today's Objective-C world, most folks use a 2 letter prefix to try and achieve this, but all too often, Apple will add an API that hijacks an in use 2 letter prefix. This is not exclusive to Apple either. If I bring in a third party framework, I have to be sure there are no class name collisions. If they were in their own namespace, I'd have no worry.

I'd suggest reverse domain style like Java.

This could be backwards compatible by having any class that doesn't define a namespace be in the general namespace. Apple could then leave all existing APIs in the general namespace for backwards compatibility and all new API (as well as third party code) would use namespaces.

Steps to reproduce:

Create a class with the same name as one in a framework you've included and watch mass confusion commence.

Expected results:

Allow for the definition of namespaces to allow for classes of the same name to co-exist in the same application.

Actual results:

No such feature exists. Hacks and work arounds are put in place that aren't guaranteed to work.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!