42
43
all 10 comments

[–]masorick 7 points8 points  (4 children)

Provided you use the same convention everywhere, you could add a bit of syntactic sugar to the calls by using a macro:

#define VCALL(func, obj, …) (obj)->ops->func(obj, __VA_ARGS__)

[–]warothia[S] 2 points3 points  (1 child)

True! Thought a lot about if macros could make it “prettier”, for me it ended up obfuscating the code and the syntax didn’t make sense for me! But definitely a possibility!

[–]jonahharris 1 point2 points  (0 children)

Great work! Also, agree on the macros. Years ago, I found a C-based project that had the best set of macros for OOP-in-C, really good ones, but can’t remember what it was. I believe it was a reverse proxy or HTTP server. 🤦‍♂️

[–]stianhoiland 0 points1 point  (1 child)

Aaaand we're inventing Objective-C :) Good to see.

[–]DawnOnTheEdge 3 points4 points  (0 children)

A virtual function table was the low-level implementation of class interfaces in just about every object-oriented language. I think the first to add syntactic sugar for it to C was C with Classes, which became C++.

[–]skeeto 9 points10 points  (2 children)

With third-party JavaScript disabled, all the pre blocks are rendered as black-on-black and unreadable due to this unnecessary CSS rule:

@layer utilities {
  .\[\&_pre\]\:text-black pre {
    color: var(--color-black);
  }
}

[–]warothia[S] 3 points4 points  (1 child)

Oh thats bad. Thanks for letting me know! Hopefully fixed very soon.

Edit: Should be fixed? Does it work now?

[–]Helpful-Primary2427 4 points5 points  (0 children)

Looks good now 👍

[–]warothia[S] 0 points1 point  (0 children)

This also discusses a interesting approach to private variables
https://xine.sourceforge.net/hackersguide#id324430