3 ms·
It’s not a “mistake”. This article is complaining about a misinterpretation of C’s functionality. Arrays are not “real” data structures in C: there’s no such th
by skywhopper 6y ago
It’s not a “mistake”. This article is complaining about a misinterpretation of C’s functionality. Arrays are not “real” data structures in C: there’s no such thing. The array-ish syntax that’s available is just a some syntactic sugar on top of pointers. You could say that having the sugar at all is a mistake. Or that C is incomplete without first-class array types. This is a cute hack, but at this point (far more than 10 years ago) it’s probably better to move on to Rust if you don’t like this aspect of C, rather than proposing to hack the language.
- WalterBright 6y ago> Arrays are not “real” data structures in C: there’s no such thing. I assure you, there are arrays in C. int a[100]; // `a` is an array, not a pointer int* p; // `p` is a pointer, not an array a = p; // error, array is not a pointer > The array-ish syntax that’s available is just a some syntactic sugar on top of pointers. Sorry, this is incorrect. In some circumstances, C will implicitly convert an array to a pointer, which is what the article is about, but don't mistake a conversion with identity.
- teddyh 6y agoSee chapter 6 of the C FAQ: http://c-faq.com/aryptr/ http://c-faq.com/aryptr/