|
|
|
|
|
by preg_match
10 days ago
|
|
This is very unreliable overall and since the type system is so primitive, you’re limited on what you can enforce on the structure. You can easily break stuff accidentally. For example: suppose you need a container to hold ints. But it also needs to be able to hold other types. In C++ this is trivial, as in virtually all modern languages. In C this is impossible. You can have a generic memory backed storage + accessors. But if you rely on void pointer functions, you have to remember every time to cast and pinky promise to only store one type. It’s very, very easy to make a mistake, and you will. Most abstractions that we take for granted in modern languages are straight up not possible in C, or at least they are extremely incomplete. Part of that is because you can’t get C to do anything automatically. Every function call must be manual. |
|
Here is an example for a generic vector type: https://godbolt.org/z/7MdGqcdbq
Your mistake is believing that you need native syntax for such feature to be possible. But this is not true.