3 ms·
> This is easily corrected in C by adding a small extension Unfortunately, easily corrected it is not. Yes, probably >95% of arrays have a nearby easily-access
by jcranmer 2y ago
> This is easily corrected in C by adding a small extension
Unfortunately, easily corrected it is not. Yes, probably >95% of arrays have a nearby easily-accessible length parameter that indicates their maximum legal length (excluding the security disaster of null-terminate strings). But the problem is there's no consistent way that people do this. Sometimes people put pointer first and size second, sometimes it's the other way around. Sometimes the size is a size_t, sometimes an unsigned, sometimes an int. Or sometimes it's not a pointer-and-size, but pointer and one-past-the-end pointer pair. Sometimes multiple arrays share the same size parameter.
So instead of an easy solution getting you 90% for effectively free, you get like 30% with the easy solution, and have to make it more complicated to handle the existing diversity to push it back up to that 90%.
- WalterBright 2y agoThis extension was added in D at its start, and 25 years of experience with it shows that it is possibly D's best loved feature. It's a huge win.