Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

What are advantages of using Sepples?

Name: Anonymous 2016-10-08 7:49

1.templates are easily replaced by macros and _Generic (which selects arguments by compile-time type(without any float/int promotions!)
2.function overload is replaced by above as well.
3.Classes are essentially structs with function pointers.
GCC supports constructors(attribute constructor) and destructors(attribute cleanup) in plain C
http://stackoverflow.com/questions/1113409/attribute-constructor-equivalent-in-vc
http://echorand.me/site/notes/articles/c_cleanup/cleanup_attribute_c.html
4.constexpr can be rewritten as expression macros ({macro;return var;}) which will be optimized via constant propogation(but unlike constexpr can be runtime dependent).
5.GCC has new apply function for plain C
https://gcc.gnu.org/onlinedocs/gcc/Constructing-Calls.html#Constructing-Calls
6.Thread-safe atomics built-ins in Plain C
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html#g_t_005f_005fatomic-Builtins

Name: Anonymous 2016-10-10 13:58

>>8

operator overloading
lambdas

These are two conveniences that I wish C had. First-class functions are extraordinarily useful, and it's nice to be able to type v1 += v2 instead of v1 = vec2_add(v1, v2). Clang has support for blocks, which are a decent enough alternative to lambdas.

On the other hand, I don't understand the point of wrapping things up into classes. If you want an object-oriented approach in C, you can do:

typedef struct {
// ...
} MyStruct;

...

my_struct_operation(MyStruct *s, ...);


Make MyStruct an opaque type and define getters, setters, and a constructor for it if you need really that level of encapsulation.

In C++, you have structs AND CLASSES that can both have functions defined within them, while private properties are defined in the headerfile. Wtf? It's literally the same amount of typing (or more) than what you'd get in C, two keywords that do the same thing, and it violates the fundamental tenets of encapsulation. This is the defining feature of C++ compared to C, yet it wasn't necessary to write a new programming language to do this.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List