3 ms·
All it takes is a pointer to some prototype struct shared by all instances; let's call it VMT. Congrats, we have reinvented canonical OOP classes, in their cru
by nine_k 3y ago
All it takes is a pointer to some prototype struct shared by all instances; let's call it VMT.
Congrats, we have reinvented canonical OOP classes, in their crudest form, and without any syntax sugar. We can still make the type system give us some static guarantees for presence of the methods, and maybe the compatibility between methods we put into slots, and instances they'll have to operate on.
We're on the way of inventing ObjC, JavaScript, or C++, depending on how bad our tastes are %)