News for hackers. Stuff that matters.
Re:OOP in C by zozbot234 on Sunday January 08, 2023 @07:02AM (#34298378)
You need to use a void* self pointer. And to indirect through the vtable in all calls to virtual methods, even those that are part of the object itself. Thus, e.g. a method defined on a base class might end up calling an implementation deep in the inheritance hierarchy, that didn't even exist when the base class code was written. There's no real equivalent to this when doing simple interface inheritance, but it's very much part of the actual semantics here.
Re:OOP in C by l- on Sunday January 08, 2023 @02:00PM (#34301942)
> You need to use a void* self pointer

Where there is a will there are pointers to function pointers: https://stackoverflow.com/questions/4393716/is-there-a-a-way...

A closure is a poor man’s object; an object is a poor man’s closure” (2003) https://news.ycombinator.com/item?id=14235020