4 ms·
You don't need a vtable for overloading; that is just runtime polymorphism ("ad hoc polymorphism". Function overloading can be done compile time, eg., parametr
by mjburgess 6y ago
You don't need a vtable for overloading; that is just runtime polymorphism ("ad hoc polymorphism".
Function overloading can be done compile time, eg., parametrically:
add(3.0, 1.0) -> compile to add_float32_float32
add(1, 2) -> compile to add_int32_int32
- fctorial 6y agoAs I said, `add` function in C maps to a symbol named `add` in assembly. You're demangling the function name, which is what C++ does.
- mjburgess 6y agoSure, you're right. I guess we'd need C to have a special syntax to compile in something like a vtable add_f32_f32(x, y) calls add(MAGIC_NO, x, y) and add has a big switch on MAGIC_NO for selecting implementation... You'd need a keyword for this, "multi int add(int a, int b) ..."
- jcelerier 6y agosuch complications where this is what C++ gives you natively