Joseph wrote:
> 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").

Exactly! This is what eventually persuaded me to stop doubting that 'length'
is the most appropriate term (and I did sincerely doubt it, for a while).

We can't eliminate such off-by-one errors from programs by choice of
terminology, and certainly not by a retroactive change in terminology.

________________________________________
From: Joseph Myers <josmy...@redhat.com>
Sent: 08 October 2024 16:13
To: Alejandro Colomar
Cc: gcc-patches@gcc.gnu.org; Gabriel Ravier; Jakub Jelinek; Kees Cook; Qing 
Zhao; Jens Gustedt; David Brown; Florian Weimer; Andreas Schwab; Timm Baeder; 
Daniel Plakosh; A. Jiang; Eugene Zelenko; Aaron Ballman; Paul Koning; Daniel 
Lundin; Nikolaos Strimpas; JeanHeyd Meneide; Fernando Borretti; Jonathan 
Protzenko; Chris Bazley; Ville Voutilainen; Alex Celeste; Jakub Łukasiewicz; 
Douglas McIlroy; Jason Merrill; Xavier Del Campo Romero; Siddhesh Poyarekar; DJ 
Delorie; Carlos O'Donell; Stephen Coady; Robert Seacord
Subject: Re: [PATCH v13 0/4] c: Add __lengthof__ operator

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.  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.".  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").

--
Joseph S. Myers
josmy...@redhat.com

Reply via email to