3 ms·
An example would be dynamic dispatch of virtual functions. In C++ virtual functions are implemented as vtables attached to each object. As such you need to ret
by lucozade 12y ago
An example would be dynamic dispatch of virtual functions.
In C++ virtual functions are implemented as vtables attached to each object. As such you need to retrieve the object (possibly from the heap), there's a function pointer indirection, there may be trampolines if you're using multiple inheritance. That sort of thing.
The author has a nice piece in the documentation regarding how dynamic dispatch is implemented in loci in order to support structural typing. He explains the design choice, how it differs from C++ (a vtable at each interface reference call site) and gives some qualitative estimates as to how the performance would differ. It's worth the read.
C doesn't have dynamic dispatch built in to the language. If you want it, you'd have to code it by hand.