4 ms·
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 o
by fleitz 14y ago
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
- cageface 14y agoIf 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.
- pjmlp 14y ago> 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.
- cageface 14y agoIn 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.
- pjmlp 14y agoYou 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.
- deleted 14y ago[deleted]
- fleitz 14y agoThe 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.