HoTT wrote:Please keep in mind that I'm not condemning these features. They're useful, but should only belong in applications programming languages, not systems programming languages.
I don't see why name mangling only belongs into application programming languages. In regards to classes, the bitc developer are now convinced that
every system programming language needs some kind of inheritance/subtyping. I think they're right.
When you're working close to the metal, there should never be any code generated or executed that the developer themselves cannot see.
So the code generated for a virtual function call does not belong to a system programming language, but the code emitted for normal function calls (prolog, epilog, parameter passing, stack management) is okay? Why draw the line there? What about macros? Wouldn't macros violate the rule as well?
Name mangling only belongs to applications programming because it's implementation specific and it obscures the use of functions from the developer. It's like saying,
Code: Select all
void kmain (void) __attribute__ ((alias ("main"))) {}
When the developer expects to call "kmain", but is being redirected to something different. In this case, there is a sort of inversion of control where the language is telling the programmer what symbol to use rather than the other way around.
The line is drawn between normal emitted function calls and virtual function calls because at that point, the programmer is still explicitly directing the control flow of the program. When you use virtual calls, you are relying on late binding; which implies there is a system underneath you controlling how things link together, rather than you being the one to control the system.
Yes, macros do break this system. You may be wanting to call 'printf' but a macro may replace that with 'pspDebugScreenPrintf'. In C though, the use of macro's is not part of the language, it's part of the preprocessor. Compiling C code is like translating your code 3 times. 'C+MacroProcessing -> C -> Assembly -> Machine Code'. (which is exactly what GCC does; *.c -> *.i -> *.s -> *.o)
EDIT:
I should add that the reason that macros are acceptable in systems programming are that they control the system from above rather than from below. They are always processed before compilation time, so behavior is deterministic.