3 ms·
It's not inherent in C being a low-level language that it has such a painful memory model. It's a consequence of having to fit the compiler into a really tiny m
by Animats 5y ago
It's not inherent in C being a low-level language that it has such a painful memory model. It's a consequence of having to fit the compiler into a really tiny machine by modern standards. Originally, there were no function prototypes.
I once proposed a backwards-compatible way out for C.[1] Basically, you get to talk about arrays as objects with a length, even if that length is in some other variable. And you get slices and references.
It was discussed enough to establish that it could work, but the effort to push it forward wasn't worth it.
Slices are important. They let you do most of the things people do with pointer arithmetic. Once you have size and slices, you can still operate near the memory address level.
[1] http://www.animats.com/papers/languages/safearraysforc43.pdf http://www.animats.com/papers/languages/safearraysforc43.pdf
- WalterBright 5y agoIt's similar to what I proposed in 2009: https://www.digitalmars.com/articles/C-biggest-mistake.html https://www.digitalmars.com/articles/C-biggest-mistake.html except mine is much simpler :-) The proven utility and effectiveness of this is apparent in D.
- pjmlp 5y agoBy now it should be clear that WG14 doesn't care about improving C's safety. A type like yours could be added, just like a string library like SDS, but it will never happen.