[cfe-dev] Adding namespaces to Objective-C

Owen Shepherd owen.shepherd at e43.eu
Tue Nov 9 09:47:11 PST 2010


As someone interested in contributing to Clang - and, in particular, contributing to its Objective-C(++) support, I would like to hear people's thoughts with regards to adding support for namespaces to Objective-C.

Some thoughts:
1.	 Do we make this an extension to Objective-C, or to C itself? From my point of view, each way primarily boils 
	down to a matter of syntax: As an Objective-C extension, the keyword would likely be "@namespace"; while 
	as a C extension it would probably be "__namespace__" (or maybe just "namespace" in a hypothetical 
	"clang99"  mode)
2.	Function name mangling. Function names follow the platform's C++ ABI (Much like the existing 	
	__attribute__((overloadable)) does*
3.	When class names are involved in Objective-C symbols, then namespaced classes are mangled similarly to 
	C++ names are; a hypothetical MyNS::MyClass is mangled as 4MyNS7MyClass. This is backwards 	
	compatible; traditional class names cannot start with numbers
4.	The added namespace declarations are equivalent to and interchangeable with C++ " namespace" 
	declarations. 

Do any other people have any comments, or any thoughts on how best to stage this? 

* At least for a first pass. It would seem prudent to define a different name mangling scheme for C namespaces long term. Perhaps we again take advantage of the illegality of numbers at the start of identifier names and mangle function names the same way we do classes?

-- Owen Shepherd
http://www.owenshepherd.net/
owen.shepherd at e43.eu (general) / oshepherd1 at shef.ac.uk (university)

P.S. Any estimates on when the official Git mirror will be available? I find Git to be incredibly useful for managing one's changes outside the official repository.



More information about the cfe-dev mailing list