Re:What is the best way to solve an Objective-C namespace co...
by fleitz on Sunday May 20, 2012 @12:34AM
(#3997953)
Java/C# solve this problem, yet in those languages it's possible for one compiler's code to link with another.
Namespace mangling and more importantly a lack of standard for it are not required to implement namespaces.
In Obj-C it really wouldn't be that difficult to make an @namespace directive that just prepended the namespace to the class.
@namespace com.apple.foo
@interface Bar : NSObject
@end
Could be semantically equivalent to @interface com_apple_foo_Bar
@end
Re:What is the best way to solve an Objective-C namespace co...
by cageface on Sunday May 20, 2012 @01:22AM
(#3998022)
If you're running in a virtual machine you have a lot more flexibility to solve these kinds of problems, of course.
I wouldn't mind seeing explicit namespace support in Obj-C although I can't say I've run into any namespace clashes in my own code yet.
Re:What is the best way to solve an Objective-C namespace co...
by pjmlp on Sunday May 20, 2012 @03:29AM
(#3998213)
> If you're running in a virtual machine you have a lot more flexibility to solve these kinds of problems, of course.
Why so? Since the late 70's every language that supports modules has already solved this problem, and many of them have native code compilers.
Re:What is the best way to solve an Objective-C namespace co...
by cageface on Sunday May 20, 2012 @12:38PM
(#3999222)
In a vm you can do dynamic loading and bytecode manipulation tricks that are much harder to do in native code. Look at all the crazy AOP stuff people have done on the JVM.
Re:What is the best way to solve an Objective-C namespace co...
by pjmlp on Sunday May 20, 2012 @01:28PM
(#3999395)
You can do the same in native code, it just a bit harder to do.
That is how you do cool demoscene stuff in 4096K or less, with lots of self rewriting code.
Re:What is the best way to solve an Objective-C namespace co...
by fleitz on Sunday May 20, 2012 @04:55PM
(#4000066)
The VM is irrelevant, C compilers can call each others code, why can't code from one C++ compiler call code from another?
It has nothing to do with the VM and everything to do with the implementation of namespaces/calling conventions being 'undefined'
It's insane.
On the other hand, with a carefully chosen three letter prefix these kinds of collisions should be pretty rare in practice.