Pointer/length is not just for strings - but for all arrays.
See my proposal:
Pointer/length is not just for strings - but for all arrays.
See my proposal:
Could I pick your brain a little more on the design? I'm spader at spader.zone; if you have time, drop me an email. I promise not to take too much of your time and I'd love to hear from you.
This can get you started:
https://dlang.org/spec/arrays.html
Strings (and arrays) being length/ptr is a freaking enormous win, in simplicity, performance, and overflow bug elimination.
One of D's secret features is that string literals still have a 0 appended to them, even though the length of the string does not include the 0. This makes it super slick to call C functions, like printf, using a string literal for the format string.
I'm baffled why C spends its energy doing things like normalized Unicode identifiers (an abomination) instead of something incredibly useful like length/ptr arrays.
https://github.com/gritzko/libabc
In this day and age, the top problem is Claude bringing lots and lots of bad C into the code base. Takes a weekend to clear the week's mess.
https://github.com/gritzko/beagle
In a cleared codebase though all the usual C memory bugs are virtually non-existant. When did I see core dump last time? I do not remember. Thus feel no urge to use Zig or Rust.
Interestingly, I rarely make a memory bug these days. Too much experience, I've just learned not to make them.
But I still prefer to use language features that make it easier to not make such errors.
It hasn't been much of an issue with decades of D code.