[CC -= Jens] Hi Joseph,
On Tue, Oct 08, 2024 at 03:13:19PM GMT, Joseph Myers wrote: > On Tue, 8 Oct 2024, Alejandro Colomar wrote: > > > > I have plenty of concerns with > > > both the wording and incompatibility of various changes suggested there > > > related to what's allowed as a sizeof operand and associated semantics > > > but > > > I don't think there were any concerns in that discussion about the use of > > > the term "length". > > > > Now you've seen mine. I will oppose to n3187 as much as I can, as long > > as it offers length as the term. > > It's "size", not "length", that has been used more inconsistently. Completely agree. In fact, I've always supported using NITEMS() for things like #define STRLCPY(d, s) strlcpy(d, s, NITEMS(d)) <https://lore.kernel.org/all/2jxak5v6dfxlpbxhpm3ey7oup4g2lnr3ueurfbosf5wdo65dk4@srb3hsk72zwq/> However, at least the term size doesn't result in off-by-one issues. With char-sized elements, it's not a problem. And with wider elements, it's so obviously different from the size, that people know what they're doing. And, I don't see why the standard couldn't just standardize on "number of elements". I don't see a need for using "length" in ISO C. I think removing the phrase "number of elements" from ISO C would be negative --yes, Jens suggested he intended to do that in an eventual revision of his paper, which prompted me attempting to shoot it down with n3327--. > Take > for example this sentence from K&R2 (I don't have K&R1), section 4.9 > (Initialization): "When the size of the array is omitted, the compiler > will compute the length by counting the initializers, of which there are > 12 in this case.". Heh. :) > Length of strings is simply array length of a > sub-array that doesn't include the terminating null character (a case of > the sub-object issue of exactly what object is relevant in what context, > not anything to do with the term "length"). I thought of that, and I temporarily tried to convince myself that the term can be used to mean that. However, I don't fully convince myself that programmers won't fall into off-by-one bugs due to this. If you believe I'm wrong, I think it's okay. I wouldn't mind if you want to sed(1) the name yourself from my patch. But in good faith, I cannot send that patch. You'll have to add your signature, and add a line saying you changed the name of the operator. But please go ahead if that's what you think is best. After all, we've had our arguments, and there's no clear consensus on either side, so a maintainer has to emit the final decision. Whatever you decide, I'll be okay with it. Have a lovely night! Alex -- <https://www.alejandro-colomar.es/>
signature.asc
Description: PGP signature