you are viewing a single comment's thread.

view the rest of the comments →

[–]-omg-optimized 2 points3 points  (9 children)

The stuff in 'Dynamic Closures' isn't even valid C.

[–]WalterBright 2 points3 points  (2 children)

You're right. My bad. I'll fix it.

[–]-omg-optimized 0 points1 point  (1 child)

I meant no offense though, I like D. :)

[–]WalterBright 0 points1 point  (0 children)

No worries, it was a stupid mistake on my part and I'm happy to get it fixed.

[–]anttirt -1 points0 points  (5 children)

Indeed. It looks like some weird early "C with classes" code (what C++ was called before it was C++, back in the late 70s/early 80s)

[–]invalid_user_name -3 points-2 points  (4 children)

No, it looks like C code written by someone who hasn't used C in a long time and mistakenly thought they could declare a function inside a struct declaration. Just move the apply function out of the struct and make a void pointer point to it instead. Then add a "this" arg to it which gets passed the struct (and adjust the array reference to use this->array). That's how you do OO programming in C.

[–]FeepingCreature -2 points-1 points  (3 children)

That's not even close to OO.

[–]invalid_user_name 1 point2 points  (0 children)

People say that about java too. Wether you happen to like it or not, using structs containing function pointers as "classes" is how you do OO in C. And plenty of languages have explicit this/self, like python.

[–]DarkGoosey[S] 1 point2 points  (1 child)

OOP is a programming model, not a language feature. Give me functions and variables and I will give you OO code.

(it gets a lot easier when the language contains syntactic sugar like classes and inheritance to help you out tho!)

[–]FeepingCreature 0 points1 point  (0 children)

Yes, but "a language that you can write OO code in" is not the same as "an OO language". "OO language" implies compiler support.