News for hackers. Stuff that matters.
Re:Object-oriented techniques in C by dimonomid on Tuesday September 22, 2015 @05:01PM (#10261682)
> First you add an extra function pointer for any member, even if it's not virtual

Wrong. If some function is not virtual, there's no point to add it to vtable; so, it's just a regular function.

> Also the first technique doesn't feel like OO in any meaningful way.

Really? Of course I can be wrong, but for me, defining a state object and operate on it only through methods (i.e. functions that are given a pointer to state object) is exactly what is called an OO style.

Re:Object-oriented techniques in C by MichaelGG on Tuesday September 22, 2015 @07:31PM (#10262456)
Thanks for the correction. I had misread and thought all functions were called with member syntax.

I guess in simple cases like this the difference between OO and other styles are pointless. I'm just thinking that if I were to write it in a functional language, it'd probably a very similar API, though possibly/probably returning a new state vs modifying.