3 ms·
How does this fix it? It automatically includes a size_t with all array types but does it also rely on the programmer setting the size_t value correctly? If so
by krferriter 8y ago
How does this fix it? It automatically includes a size_t with all array types but does it also rely on the programmer setting the size_t value correctly? If so there will be the same problems. It seems like this is exactly the same as just passing a size argument along with all array-type arguments, which is already common practice.
- WalterBright 8y ago> does it also rely on the programmer setting the size_t value correctly? For static arrays, no, the compiler does it. For turning pointers into phat pointers, yes, the user has to supply the length. But he only has to do that once. > exactly the same It isn't, for the reasons: 1. The compiler knows about it, so it can be used for optimization purposes, and to optionally insert bounds checking or not. 2. Consider why C has structs. It's because it's a lot less error prone to group related values together, rather than having a collection of independent variables. It makes the code easier to read, too.