Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Many alligators will be slain, but the swamp will remain.


devel / comp.lang.c / Re: Do you insist on const-correctness?

SubjectAuthor
* Do you insist on const-correctness?Anton Shepelev
+- Re: Do you insist on const-correctness?Anton Shepelev
+* Re: Do you insist on const-correctness?Ben Bacarisse
|`* Re: Do you insist on const-correctness?Anton Shepelev
| +* Re: Do you insist on const-correctness?David Brown
| |`* Re: Do you insist on const-correctness?David Brown
| | `* Re: Do you insist on const-correctness?comp.lang.c
| |  `* Re: Do you insist on const-correctness?David Brown
| |   +* Re: Do you insist on const-correctness?Keith Thompson
| |   |`- Re: Do you insist on const-correctness?Chris M. Thomasson
| |   +- Re: Do you insist on const-correctness?Scott Lurndal
| |   +* Re: Do you insist on const-correctness?David Brown
| |   |`- Re: Do you insist on const-correctness?Chris M. Thomasson
| |   `- Re: Do you insist on const-correctness?Keith Thompson
| `* Re: Do you insist on const-correctness?Ben Bacarisse
|  `- Re: Do you insist on const-correctness?Anton Shepelev
+* Re: Do you insist on const-correctness?Tim Rentsch
|`* Re: Do you insist on const-correctness?Anton Shepelev
| +* Re: Do you insist on const-correctness?David Brown
| |+* Re: Do you insist on const-correctness?Scott Lurndal
| ||+* Re: Do you insist on const-correctness?Kaz Kylheku
| |||`* Re: Do you insist on const-correctness?Bart
| ||| +* Re: Do you insist on const-correctness?Kaz Kylheku
| ||| |`* Re: Do you insist on const-correctness?Bart
| ||| | +- Re: Do you insist on const-correctness?Chris M. Thomasson
| ||| | +- Re: Do you insist on const-correctness?Kaz Kylheku
| ||| | +- Re: Do you insist on const-correctness?Keith Thompson
| ||| | `- Re: Do you insist on const-correctness?David Brown
| ||| +* Re: Do you insist on const-correctness?David Brown
| ||| |`* Re: Do you insist on const-correctness?Bart
| ||| | +- Re: Do you insist on const-correctness?Ben Bacarisse
| ||| | +- Re: Do you insist on const-correctness?Keith Thompson
| ||| | +* Re: Do you insist on const-correctness?Kaz Kylheku
| ||| | |`* Re: Do you insist on const-correctness?Chris M. Thomasson
| ||| | | `* Re: Do you insist on const-correctness?Keith Thompson
| ||| | |  `* Re: Do you insist on const-correctness?Chris M. Thomasson
| ||| | |   `* Re: Do you insist on const-correctness?Keith Thompson
| ||| | |    `- Re: Do you insist on const-correctness?Chris M. Thomasson
| ||| | `* Re: Do you insist on const-correctness?David Brown
| ||| |  `* Re: Do you insist on const-correctness?Bart
| ||| |   `* Re: Do you insist on const-correctness?David Brown
| ||| |    `* Re: Do you insist on const-correctness?Bart
| ||| |     +- Re: Do you insist on const-correctness?Keith Thompson
| ||| |     +- Re: Do you insist on const-correctness?Kaz Kylheku
| ||| |     `- Re: Do you insist on const-correctness?David Brown
| ||| +- Re: Do you insist on const-correctness?Keith Thompson
| ||| `* Re: Do you insist on const-correctness?James Kuyper
| |||  `* Re: Do you insist on const-correctness?Bart
| |||   `* Re: Do you insist on const-correctness?David Brown
| |||    `* Re: Do you insist on const-correctness?Kaz Kylheku
| |||     `- Re: Do you insist on const-correctness?Chris M. Thomasson
| ||`* Re: Do you insist on const-correctness?David Brown
| || `* Re: Do you insist on const-correctness?Chris M. Thomasson
| ||  `* Re: Do you insist on const-correctness?Chris M. Thomasson
| ||   `* Re: Do you insist on const-correctness?Ben Bacarisse
| ||    `* Re: Do you insist on const-correctness?Chris M. Thomasson
| ||     `* Re: Do you insist on const-correctness?Ben Bacarisse
| ||      `- Re: Do you insist on const-correctness?Chris M. Thomasson
| |+* Re: Do you insist on const-correctness?Kaz Kylheku
| ||`* Re: Do you insist on const-correctness?David Brown
| || `* Re: Do you insist on const-correctness?Anton Shepelev
| ||  `* Re: Do you insist on const-correctness?David Brown
| ||   `* Re: Do you insist on const-correctness?Anton Shepelev
| ||    `- Re: Do you insist on const-correctness?David Brown
| |`* Re: Do you insist on const-correctness?Anton Shepelev
| | +- Re: Do you insist on const-correctness?Bart
| | +- Re: Do you insist on const-correctness?Richard Damon
| | +* Re: Do you insist on const-correctness?Scott Lurndal
| | |`- Re: Do you insist on const-correctness?Anton Shepelev
| | `* Re: Do you insist on const-correctness?David Brown
| |  +* Re: Do you insist on const-correctness?Bart
| |  |`* Re: Do you insist on const-correctness?David Brown
| |  | `* Re: Do you insist on const-correctness?Bart
| |  |  +* Re: Do you insist on const-correctness?Chris M. Thomasson
| |  |  |`* Re: Do you insist on const-correctness?Bart
| |  |  | +* Re: Do you insist on const-correctness?Chris M. Thomasson
| |  |  | |`- Re: Do you insist on const-correctness?Bart
| |  |  | +* Re: Do you insist on const-correctness?David Brown
| |  |  | |`* Re: Do you insist on const-correctness?Chris M. Thomasson
| |  |  | | +- Re: Do you insist on const-correctness?Kaz Kylheku
| |  |  | | `* Re: Do you insist on const-correctness?David Brown
| |  |  | |  `* Re: Do you insist on const-correctness?Chris M. Thomasson
| |  |  | |   `- Re: Do you insist on const-correctness?Chris M. Thomasson
| |  |  | `* Re: Do you insist on const-correctness?Anton Shepelev
| |  |  |  +* Re: Do you insist on const-correctness?Anton Shepelev
| |  |  |  |`- Re: Do you insist on const-correctness?David Brown
| |  |  |  +- Re: Do you insist on const-correctness?Bart
| |  |  |  +* Re: Do you insist on const-correctness?Dan Cross
| |  |  |  |`* Re: Do you insist on const-correctness?Anton Shepelev
| |  |  |  | `* Re: Do you insist on const-correctness?Dan Cross
| |  |  |  |  `* Re: Do you insist on const-correctness?Scott Lurndal
| |  |  |  |   `- Re: Do you insist on const-correctness?Dan Cross
| |  |  |  `* Re: Do you insist on const-correctness?David Brown
| |  |  |   +* Re: Do you insist on const-correctness?Bart
| |  |  |   |+* Re: Do you insist on const-correctness?Kaz Kylheku
| |  |  |   ||+* Re: Do you insist on const-correctness?Bart
| |  |  |   |||`* Re: Do you insist on const-correctness?David Brown
| |  |  |   ||| +- Re: Do you insist on const-correctness?Anton Shepelev
| |  |  |   ||| `* Re: Do you insist on const-correctness?Bart
| |  |  |   |||  `* Re: Do you insist on const-correctness?David Brown
| |  |  |   |||   `* Re: Do you insist on const-correctness?Ben Bacarisse
| |  |  |   ||`* Re: Do you insist on const-correctness?David Brown
| |  |  |   |`- Re: Do you insist on const-correctness?David Brown
| |  |  |   +* Re: Do you insist on const-correctness?Anton Shepelev
| |  |  |   +* Re: Do you insist on const-correctness?David Brown
| |  |  |   `- Re: Do you insist on const-correctness?Chris M. Thomasson
| |  |  `- Re: Do you insist on const-correctness?David Brown
| |  `* Re: Do you insist on const-correctness?Anton Shepelev
| `* Re: Do you insist on const-correctness?Tim Rentsch
+* Re: Do you insist on const-correctness?Kaz Kylheku
`- Re: Do you insist on const-correctness?Tim Rentsch

Pages:12345678
Re: Do you insist on const-correctness?

<uf1ml5$36bge$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29332&group=comp.lang.c#29332

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 18:52:52 +0200
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <uf1ml5$36bge$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 16:52:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="15512179f25db77e54e52f295a88dc6e";
logging-data="3354126"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+dg1EVlKXuMR78R67N/gNvZEzqen6p2yw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:FsH5ruSqW0vii1QAiAp+Wh5O8SE=
In-Reply-To: <bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Wed, 27 Sep 2023 16:52 UTC

On 27/09/2023 17:35, Malcolm McLean wrote:
> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>
>>> (Nesting, indirection, and dimensioning are all related to each other).
>> No, they are not.
>>
> You haven't thought this through, have you?

Yes, I have.

I mean, obviously if you want to have an n-dimensional array and loop
through it all, you'll have n levels of nesting, and your array access
is technically through pointers with n levels of indirection.

However, your ideas that this is all about the sacred number 3 is nonsense.

I have no problem using perhaps five levels of indirection in my code.
I'd be fine with more too, but that would be very unlikely to occur
simply because the function would be too big and complex, and would
already be split up.

I don't like more than one level of indirection, at least as raw
pointers. "*p" is fine - "**p" is asking for confusion. "xs[1][2]"
could be okay, but I rarely see use of anything more that is not better
handled with local variables for the parts.

For dimensions, two is usually the easiest. Thinking in four dimensions
is possible to some extent, but definitely hard. (Thinking about more
is fine in some ways, but then it's all pretty abstract mathematics.)

For other people, the mixes and numbers might be entirely different,
depending on their usual practices.

The numbers don't line up. They are entirely different concepts. The
only thing they have in common is a general pattern of "more is harder".

Re: Do you insist on const-correctness?

<uf1n3q$36bge$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29333&group=comp.lang.c#29333

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 19:00:42 +0200
Organization: A noiseless patient Spider
Lines: 57
Message-ID: <uf1n3q$36bge$2@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me> <ueuv1r$2iped$1@dont-email.me>
<20230926093309.110@kylheku.com> <uev5e6$2k5cd$1@dont-email.me>
<uf0t4p$314n3$1@dont-email.me> <uf17dn$33109$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 17:00:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="15512179f25db77e54e52f295a88dc6e";
logging-data="3354126"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/jkTnhxmHUeckvWx0m1gjguHisZnjbFow="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:nXby7nKfLAOn0YPcFTslv8O4YNc=
In-Reply-To: <uf17dn$33109$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Wed, 27 Sep 2023 17:00 UTC

On 27/09/2023 14:32, Bart wrote:
> On 27/09/2023 10:37, David Brown wrote:
>
>
>> I will even write something like this on occasion :
>>
>>      if (<complicated condition>) {
>>          // Everything is fine, nothing to do
>>      } else {
>>          do_something();
>>      }
>>
>> rather than
>>
>>      if (!(<complicated condition>)) {
>>          do_something();
>>      }
>>
>> It is all about what is clearest to read.
>
> I have a version of 'if' called 'unless', which sometimes reads better,
> but not always.
>
> In particular, although 'unless' can have an 'else' branch, it doesn't
> have 'else-unless'; I couldn't work out what it meant!

There are a few different varieties of conditionals that have been tried
in different programming languages. That includes syntaxes roughly like
"x = x - 1 if x > 0", or FORTH's "x ? 0 > if x ? 1 - x ! then", if I
have remembered the details correctly. I don't think it really helps to
have too many ways of doing the same thing - there has to be very clear
gains to make it worth the effort.

>
> Also, while C has 'do...while', my equivalent is 'repeat...until', with
> the opposite logic.

That's fine - I think either works well.

>
> I can't have repeat...while as that is ambiguous: the 'while' could be
> starting a new loop. Actually I had some troubling figuring out how C
> manages to avoid the same problem.
>
>
> (Note that I can write C's
>
>     do {a;b;c;} while (cond);
>
> as:
>
>     while a;b;c; cond do end
>
> Ugly, though.)
>
>

Re: Do you insist on const-correctness?

<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29334&group=comp.lang.c#29334

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:8d:b0:417:fa13:5bbb with SMTP id o13-20020a05622a008d00b00417fa135bbbmr35919qtw.8.1695836776044;
Wed, 27 Sep 2023 10:46:16 -0700 (PDT)
X-Received: by 2002:a9d:6b84:0:b0:6b9:182b:cebc with SMTP id
b4-20020a9d6b84000000b006b9182bcebcmr645533otq.7.1695836775842; Wed, 27 Sep
2023 10:46:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 27 Sep 2023 10:46:15 -0700 (PDT)
In-Reply-To: <uf1ml5$36bge$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:f919:d1df:b42:2927;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:f919:d1df:b42:2927
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com> <20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me> <20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc> <ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com> <uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com> <uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com> <uf1ml5$36bge$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
Subject: Re: Do you insist on const-correctness?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 27 Sep 2023 17:46:16 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2902
 by: Malcolm McLean - Wed, 27 Sep 2023 17:46 UTC

On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
> On 27/09/2023 17:35, Malcolm McLean wrote:
> > On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
> >> On 27/09/2023 12:37, Malcolm McLean wrote:
> >>
> >>> (Nesting, indirection, and dimensioning are all related to each other).
> >> No, they are not.
> >>
> > You haven't thought this through, have you?
> Yes, I have.
>
> I mean, obviously if you want to have an n-dimensional array and loop
> through it all, you'll have n levels of nesting, and your array access
> is technically through pointers with n levels of indirection.
>
Exactly. Not exactly a controversial idea, is it?
Nesting, indirection, and dimensioning are all related to each other.
And we can visualise three dimensions easily enough, because we live
in a world with three dimensions of space. To visualise four dimensions,
you have to add time, which makes it a different sort of mental exercise.

So three is the magic number.

Re: Do you insist on const-correctness?

<uf1s5c$37jjc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29335&group=comp.lang.c#29335

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 20:26:51 +0200
Organization: A noiseless patient Spider
Lines: 76
Message-ID: <uf1s5c$37jjc$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 18:26:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c183ed3a7290e43aa200c53440e0669a";
logging-data="3395180"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/8xW/KD7c73t8FVpILNXlF0rN3bPPEBV8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:+0fdKl01q+P5bYUZ5sSGtAJDX8M=
Content-Language: en-GB
In-Reply-To: <03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
 by: David Brown - Wed, 27 Sep 2023 18:26 UTC

On 27/09/2023 19:46, Malcolm McLean wrote:
> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>
>>>>> (Nesting, indirection, and dimensioning are all related to each other).
>>>> No, they are not.
>>>>
>>> You haven't thought this through, have you?
>> Yes, I have.
>>
>> I mean, obviously if you want to have an n-dimensional array and loop
>> through it all, you'll have n levels of nesting, and your array access
>> is technically through pointers with n levels of indirection.
>>
> Exactly. Not exactly a controversial idea, is it?

No, but not particularly relevant. Being able to think of a single
situation where three things might be used together does not make them
particularly related.

Let me just ask you - have you ever written code with nesting that did
not use indirection or dimensions? Of course you have. Have you ever
had a 2 or more dimensional array, and used it in a way that did not
involve indirection in the source code? Of course you have - people
write "xs[1][2]", not some mess involving multiple pointer dereference
operators. Have you ever used a pointer without nesting? Of course you
have. These concepts are not closely related or tied together, even if
they sometimes happen to be used in the same code.

> Nesting, indirection, and dimensioning are all related to each other.

No.

> And we can visualise three dimensions easily enough, because we live
> in a world with three dimensions of space.

Yes.

> To visualise four dimensions,
> you have to add time, which makes it a different sort of mental exercise.

No. You don't have to use time as the fourth dimension. Sometimes it
can be convenient, but certainly not always. Sometimes you use time as
a second or third dimension, sometimes you don't use it at all. I am
quite happy imagining Klein bottles, hypercubes and 4-simplexes with
four spacial dimensions. I am quite happy doing some maths with
many-dimensional spheres (they have a few uses, and do weird things),
with no sign of a time dimension. On the other hand, some physicists
work with one physical dimension and three time dimensions. And
sometimes it makes sense to think of all kinds of different properties
of objects as "dimensions".

Perhaps /you/ can only think of a fourth dimension as time, but please
don't project your own limitations onto others.

>
> So three is the magic number.

No.

Seriously. Just "no".

Even if you were right that nesting, indirection and dimensioning were
strongly related - even though they most certainly are not - that would
not make three a magic number.

You really have to get off this hobby-horse you have invented. The more
you repeat it and spout increasingly unsubstantiated
post-rationalisations for your obsession, the more fanatical you look.

Re: Do you insist on const-correctness?

<uf1sfp$37m2f$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29336&group=comp.lang.c#29336

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 19:32:25 +0100
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <uf1sfp$37m2f$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 18:32:25 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="07ea6ddc360482fe4d9e51f9ca54afb9";
logging-data="3397711"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18+KSkfCj4jWgE57J8w36wBEhM26jLssdA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:Z1k4rHUFeQMHPEEliC8K/sZSJdE=
In-Reply-To: <03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
 by: Bart - Wed, 27 Sep 2023 18:32 UTC

On 27/09/2023 18:46, Malcolm McLean wrote:
> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>
>>>>> (Nesting, indirection, and dimensioning are all related to each other).
>>>> No, they are not.
>>>>
>>> You haven't thought this through, have you?
>> Yes, I have.
>>
>> I mean, obviously if you want to have an n-dimensional array and loop
>> through it all, you'll have n levels of nesting, and your array access
>> is technically through pointers with n levels of indirection.
>>
> Exactly. Not exactly a controversial idea, is it?
> Nesting, indirection, and dimensioning are all related to each other.
> And we can visualise three dimensions easily enough, because we live
> in a world with three dimensions of space. To visualise four dimensions,
> you have to add time, which makes it a different sort of mental exercise.
>
> So three is the magic number.

I don't think it works. Computer source code is usually 2-dimensional,
tends to be limited horizontally, but has no particular limits vertically.

The code unit is the 'function', which are not usually that tall, as
they become unmanageable, and are not that wide either as people don't
like scrolling sideways. That's why text like this wraps onto the next
line, but that doesn't work for code which is line- not paragraph-oriented.

When talking about function nesting, my own magic number is 1, and
standard C doesn't allow more anyway. So people are welcome to limit
those to three, as I don't care!

But imagine applying the 'rule of three' to:

- The number of lines in a function

- The number of functions in a module

- The number of modules in a program

- The number of fields in a struct

It doesn't work, does it? Or is this more about nesting?

Was there also something about the number of nested parentheses in an
expression? You don't really need a rule, as it will be obvious when
there are far too many.

Re: Do you insist on const-correctness?

<87il7vsbdn.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29337&group=comp.lang.c#29337

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 11:45:56 -0700
Organization: None to speak of
Lines: 19
Message-ID: <87il7vsbdn.fsf@nosuchdomain.example.com>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf1s5c$37jjc$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="08e30d084ec8438dcadf9cbd76f2c53f";
logging-data="3399093"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/clHM+rEcwyukB3xQHDxXU"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:39GIcdfEvPqLcrDG5iK4Th95xVQ=
sha1:pi1lw4PZeLBwVQfN3dB/fbit7Js=
 by: Keith Thompson - Wed, 27 Sep 2023 18:45 UTC

David Brown <david.brown@hesbynett.no> writes:
> On 27/09/2023 19:46, Malcolm McLean wrote:
[...]
>> So three is the magic number.
>
> No.
>
> Seriously. Just "no".
[...]

David, do you think you're going to change his mind?

This discussion will end at some point without a resolution.
I suggest that now would be a good time for that.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: Do you insist on const-correctness?

<uf1v7f$389r0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29338&group=comp.lang.c#29338

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 21:19:10 +0200
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <uf1v7f$389r0$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf1s5c$37jjc$1@dont-email.me> <87il7vsbdn.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 19:19:11 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c183ed3a7290e43aa200c53440e0669a";
logging-data="3417952"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2pYXZwrsqW8uCxhWP2LH4YMh5ndpLhNw="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:EgJdN7FhVXKywXdWEBcxURnstZE=
In-Reply-To: <87il7vsbdn.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: David Brown - Wed, 27 Sep 2023 19:19 UTC

On 27/09/2023 20:45, Keith Thompson wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 27/09/2023 19:46, Malcolm McLean wrote:
> [...]
>>> So three is the magic number.
>>
>> No.
>>
>> Seriously. Just "no".
> [...]
>
> David, do you think you're going to change his mind?
>

It seems unlikely, that's true. I am afraid my tactics may have been
inspired by watching too much Black Adder. (If anyone wants a break
from discussing C, look up "Advanced World War I Tactics with General
Melchett" on youtube.)

> This discussion will end at some point without a resolution.
> I suggest that now would be a good time for that.
>

You are almost certainly right.

Re: Do you insist on const-correctness?

<20230927230537.620dabf22ed22fb31e09f9ec@gmail.moc>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29339&group=comp.lang.c#29339

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anton....@gmail.moc (Anton Shepelev)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 23:05:37 +0300
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <20230927230537.620dabf22ed22fb31e09f9ec@gmail.moc>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me>
<ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me>
<ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me>
<ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="bbee8acfd285cc8a316c79c6954e8e46";
logging-data="3435173"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+3w8Cqhu7rZpQ8EOYsv2onj+O6qO17biw="
Cancel-Lock: sha1:/4DYRgyvxioU78V5VH9lEOGZOZM=
X-Newsreader: Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
 by: Anton Shepelev - Wed, 27 Sep 2023 20:05 UTC

Malcolm McLean:
> David Brown:
> > Malcolm McLean:
> >
> > > (Nesting, indirection, and dimensioning are all
> > > related to each other).
> >
> > No, they are not.
>
> You haven't thought this through, have you?

I agree with David. Dimensions entities on the level. They
are orthogonal and equal, that is you cannot place them into
any kind of hierarchy, in which, for example, height is
below or above width. Dimensions form an unordered set (the
tautology rhetorical). Not so with nesting and indirection,
which express a hierarchy and form an ordered sequence (the
tautology rhetorical).

--
() ascii ribbon campaign -- against html e-mail
/\ www.asciiribbon.org -- against proprietary attachments

Re: Do you insist on const-correctness?

<uf267e$39oal$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29340&group=comp.lang.c#29340

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 14:18:38 -0700
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <uf267e$39oal$2@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 21:18:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="3465557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19y3Gsr7PqUKrFaG7mI5keGwZ1s0HJUlh0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:WwLswicYf37D2A8Zd8GQDpxdFUQ=
Content-Language: en-US
In-Reply-To: <499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 21:18 UTC

On 9/26/2023 8:29 AM, Malcolm McLean wrote:
> On Tuesday, 26 September 2023 at 16:11:07 UTC+1, David Brown wrote:
>> On 26/09/2023 13:37, Anton Shepelev wrote:
>>>
>>> Linus 8-chareater-tab Torvalds was IMHO right when he
>>> decreed that a function shall not have more then three
>>> levels of nesting, his enourmous tab serving as a dumb,
>>> primitive, mechanical, and ugly means of enforsing this
>>> decree.
>> No, Linus was wrong - as he is on many things. (He's right on many
>> things too, of course.) We are not using typewriters, we are not using
>> 80x25 character displays, and we do not need to have pointless
>> limitations. I don't advocate for deeply nested or overly complex
>> functions, of course - I advocate for clear code with immediately
>> obvious blocks indicated by braces /and/ indents. And if clear code
>> requires more than 3 levels of nesting, use that.
>>
> Rule of three. Three levels of nesting or indirection. Because we live in a three
> dimensional world.

Personally, I have never heard of that rule before Malcolm. However, if
I was working for you, I would learn about it and strive to follow it
because you would be my boss in this scenario. No problem.

Section 3.2 page 12:

https://www.stroustrup.com/JSF-AV-rules.pdf

Re: Do you insist on const-correctness?

<uf269e$39oal$3@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29341&group=comp.lang.c#29341

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 14:19:42 -0700
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <uf269e$39oal$3@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 21:19:42 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="3465557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19JL/XFPRjMErhb97UXonuNWQYov6ivfto="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:zGgcUVQaHYJcYluNAoljc7Nn4ug=
In-Reply-To: <03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 21:19 UTC

On 9/27/2023 10:46 AM, Malcolm McLean wrote:
> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>
>>>>> (Nesting, indirection, and dimensioning are all related to each other).
>>>> No, they are not.
>>>>
>>> You haven't thought this through, have you?
>> Yes, I have.
>>
>> I mean, obviously if you want to have an n-dimensional array and loop
>> through it all, you'll have n levels of nesting, and your array access
>> is technically through pointers with n levels of indirection.
>>
> Exactly. Not exactly a controversial idea, is it?
> Nesting, indirection, and dimensioning are all related to each other.
> And we can visualise three dimensions easily enough, because we live
> in a world with three dimensions of space. To visualise four dimensions,
> you have to add time, which makes it a different sort of mental exercise.
>
> So three is the magic number.

Well, I have some 4d fractals that might interest you.

Re: Do you insist on const-correctness?

<uf26dd$39oal$4@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29342&group=comp.lang.c#29342

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 14:21:49 -0700
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <uf26dd$39oal$4@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf269e$39oal$3@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 21:21:49 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="33a7a7a3c13bfe90a2f3511b20400978";
logging-data="3465557"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+m6660HwYkHT/ODq4N37Qge/RR7SAyAtM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:oVBjDoU00TJHDHfwo3JsKZOcpkU=
In-Reply-To: <uf269e$39oal$3@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 27 Sep 2023 21:21 UTC

On 9/27/2023 2:19 PM, Chris M. Thomasson wrote:
> On 9/27/2023 10:46 AM, Malcolm McLean wrote:
>> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>>
>>>>>> (Nesting, indirection, and dimensioning are all related to each
>>>>>> other).
>>>>> No, they are not.
>>>>>
>>>> You haven't thought this through, have you?
>>> Yes, I have.
>>>
>>> I mean, obviously if you want to have an n-dimensional array and loop
>>> through it all, you'll have n levels of nesting, and your array access
>>> is technically through pointers with n levels of indirection.
>>>
>> Exactly. Not exactly a controversial idea, is it?
>> Nesting, indirection, and dimensioning are all related to each other.
>> And we can visualise three dimensions easily enough, because we live
>> in a world with three dimensions of space. To visualise four dimensions,
>> you have to add time, which makes it a different sort of mental exercise.

Actually, how can time be a dimension in and of itself, when all
dimensions have time?

3d beings have time, 4d beings have time, ect...

>>
>> So three is the magic number.
>
> Well, I have some 4d fractals that might interest you.

Re: Do you insist on const-correctness?

<20230927143445.556@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29343&group=comp.lang.c#29343

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 22:12:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 131
Message-ID: <20230927143445.556@kylheku.com>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me> <ueuv1r$2iped$1@dont-email.me>
<20230926093309.110@kylheku.com> <uf0s9s$30uj6$2@dont-email.me>
Injection-Date: Wed, 27 Sep 2023 22:12:39 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9b3f31f8706362ec3eacce961c3d2318";
logging-data="3489798"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+bhvDYPo30knf6ffm0+j07UbqfznCk5OA="
User-Agent: slrn/pre1.0.4-9 (Linux)
Cancel-Lock: sha1:0IbU5FtyPP0noDlGrFOXdhBP+Sk=
 by: Kaz Kylheku - Wed, 27 Sep 2023 22:12 UTC

On 2023-09-27, David Brown <david.brown@hesbynett.no> wrote:
> On 26/09/2023 18:40, Kaz Kylheku wrote:
>> Indeed, I myself sometimes writes in a style like the following:
>>
>> if (condition) {
>> /* loop not needed */
>> } else for (...) {
>>
>> }
>>
>> The else keyword needs a statement, and the for statement
>> satisfies it. It has braces of its own, so everything is cool.
>
> I would not go that far. "else if" in C is, to me, a short form for
> "elseif" or "elsif" found in other languages. I've never seen an
> "elsefor" or "elsewhile" keyword.
>
> "if, else if, else" chains are common and fit a nice pattern. But a
> "for" loop is completely different, breaking the pattern - I'd have it
> in its own braces :
>
> if (...) {
> ...
> } else {
> for ( ... ) {
> ...
> }
> }

Yes; this is the widely used, familiar way of writing this situation.

I think I grew tired of it at some point.

>> The for (...) header is effectively a statement prefix which indicates
>> iteration of that statement.
>>
>> In my style, I allow the braced statement to be prefixed not only
>> by if (...) but other, similar statement introducers/prefixes
>> like while (...) and switch.
>>
>> I don't think I've ever written a
>>
>> if (this) {
>>
>> } else do {
>>
>> } while(...);
>>
>> But I totally might. :)

I wrote the above unware that I'm lying. In the TXR project, I'm
somewhat astonished to see that an "else do" occurs. What's more,
it dates back to a commit, on Christmas Day, 2011. (Ho, ho, ho!)

https://www.kylheku.com/cgit/txr/commit/?id=894aec019d3ce82f861a5777236ac079c2f2388d

in the function lazy_flatten_scan.

static val lazy_flatten_scan(val list, val *escape)
{ for (;;) {
if (list) {
val a = car(list);
if (nilp(a)) {
list = cdr(list);
} else if (atom(a)) {
return list;
} else do {
push(cdr(list), escape); /* safe mutation: *escape is a local var */
list = a;
a = car(list);
} while (consp(a));
return list;
} else if (*escape) {
list = pop(escape);
} else {
return nil;
}
}
}

I had no idea I've been doing it that long already, and that
a "do" might have started it.

In that code base there are two cases of "else for", and one "else
switch", which came later. It's far from frequent.

I can't find any instances of

else {
<for|while|switch|do> ...

>> What I wouldn't write is:
>>
>>
>> if (condition) {
>> /* loop not needed */
>> } else for (...)
>> body_expression_statement;
>>
>> Or, let alone:
>>
>> if (condition) {
>> /* loop not needed */
>> } else for (...)
>> /* empty */;
>>
>
> No, indeed.
>

The reason I wouldn't write that has nothing to do with that last
clause being an iteration statement. It's because of the same old
rule that all parts of the ladder have to be free of braces, or else all
have to have them:

This example is a "go":

if (condition)
simple_statement;
else while (--i)
foo(j++);

If simple_statement becomes a compound, then it's "no go".

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca
NOTE: If you use Google Groups, I don't see you, unless you're whitelisted.

Re: Do you insist on const-correctness?

<uf2bpe$3asqk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29345&group=comp.lang.c#29345

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 23:53:35 +0100
Organization: A noiseless patient Spider
Lines: 92
Message-ID: <uf2bpe$3asqk$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me> <ueuv1r$2iped$1@dont-email.me>
<20230926093309.110@kylheku.com> <uf0s9s$30uj6$2@dont-email.me>
<20230927143445.556@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 22:53:34 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1ef586021a048bc23a8e58600ba293f6";
logging-data="3502932"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LtyFyPHw0bCBskHCDjXpLHzxtkwVrB+s="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:6dSMwfF8PzBbEdjizVuDQ9m5f2o=
In-Reply-To: <20230927143445.556@kylheku.com>
 by: Bart - Wed, 27 Sep 2023 22:53 UTC

On 27/09/2023 23:12, Kaz Kylheku wrote:
> On 2023-09-27, David Brown <david.brown@hesbynett.no> wrote:

> https://www.kylheku.com/cgit/txr/commit/?id=894aec019d3ce82f861a5777236ac079c2f2388d
>
> in the function lazy_flatten_scan.
>
> static val lazy_flatten_scan(val list, val *escape)
> {
> for (;;) {
> if (list) {
> val a = car(list);
> if (nilp(a)) {
> list = cdr(list);
> } else if (atom(a)) {
> return list;
> } else do {
> push(cdr(list), escape); /* safe mutation: *escape is a local var */
> list = a;
> a = car(list);
> } while (consp(a));
> return list;
> } else if (*escape) {
> list = pop(escape);
> } else {
> return nil;
> }
> }
> }
>
> I had no idea I've been doing it that long already, and that
> a "do" might have started it.
>
> In that code base there are two cases of "else for", and one "else
> switch", which came later. It's far from frequent.

I don't know why this is remarkable. So, an 'else' branch has a
statement that happens to be a loop or switch statement? I'm sure that
happens all the time whether there's an intervening brace or not!

> I can't find any instances of
>
> else {
> <for|while|switch|do> ...

There are quite a few around. 25 instances in sqlite3 for example, and 5
in Lua sources. I mean, it might be 1 per 5-10K lines, but people do it.
In C, you can find instances of anything.

>>> What I wouldn't write is:
>>>
>>>
>>> if (condition) {
>>> /* loop not needed */
>>> } else for (...)
>>> body_expression_statement;
>>>
>>> Or, let alone:
>>>
>>> if (condition) {
>>> /* loop not needed */
>>> } else for (...)
>>> /* empty */;
>>>
>>
>> No, indeed.
>>
>
> The reason I wouldn't write that has nothing to do with that last
> clause being an iteration statement. It's because of the same old
> rule that all parts of the ladder have to be free of braces, or else all
> have to have them:
>
> This example is a "go":
>
> if (condition)
> simple_statement;
> else while (--i)
> foo(j++);
>
> If simple_statement becomes a compound, then it's "no go".

What about when simple_statement becomes:

if (condition) another_stmt;

Then that 'else' becomes bound to the wrong 'if'.

Re: Do you insist on const-correctness?

<uf2dt8$3arar$6@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29346&group=comp.lang.c#29346

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 16:29:44 -0700
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <uf2dt8$3arar$6@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 23:29:44 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+tpFzkvm0zOMPsOsD3Mr2CjHbTpiOupEI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:DXZLzy6vhAlD+bJ6IeisFwwFynA=
Content-Language: en-US
In-Reply-To: <03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 23:29 UTC

On 9/27/2023 10:46 AM, Malcolm McLean wrote:
> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>
>>>>> (Nesting, indirection, and dimensioning are all related to each other).
>>>> No, they are not.
>>>>
>>> You haven't thought this through, have you?
>> Yes, I have.
>>
>> I mean, obviously if you want to have an n-dimensional array and loop
>> through it all, you'll have n levels of nesting, and your array access
>> is technically through pointers with n levels of indirection.
>>
> Exactly. Not exactly a controversial idea, is it?
> Nesting, indirection, and dimensioning are all related to each other.
> And we can visualise three dimensions easily enough, because we live
> in a world with three dimensions of space. To visualise four dimensions,
> you have to add time, which makes it a different sort of mental exercise.
>
> So three is the magic number.

I personally think that time is an interesting form of quantitative
"special", and not a dimension as is simply because time exists in every
dimension. Is that kind of, fair enough?

Re: Do you insist on const-correctness?

<uf2e2g$3arar$7@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29347&group=comp.lang.c#29347

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 16:32:32 -0700
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <uf2e2g$3arar$7@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf2dt8$3arar$6@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 27 Sep 2023 23:32:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18l6rSWwu+MClEQkXEPCEF2k/kf6xxstRc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:6fr/6wTY4JBVyz3TCLX6slaZtbk=
Content-Language: en-US
In-Reply-To: <uf2dt8$3arar$6@dont-email.me>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 23:32 UTC

On 9/27/2023 4:29 PM, Chris M. Thomasson wrote:
> On 9/27/2023 10:46 AM, Malcolm McLean wrote:
>> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>>
>>>>>> (Nesting, indirection, and dimensioning are all related to each
>>>>>> other).
>>>>> No, they are not.
>>>>>
>>>> You haven't thought this through, have you?
>>> Yes, I have.
>>>
>>> I mean, obviously if you want to have an n-dimensional array and loop
>>> through it all, you'll have n levels of nesting, and your array access
>>> is technically through pointers with n levels of indirection.
>>>
>> Exactly. Not exactly a controversial idea, is it?
>> Nesting, indirection, and dimensioning are all related to each other.
>> And we can visualise three dimensions easily enough, because we live
>> in a world with three dimensions of space. To visualise four dimensions,
>> you have to add time, which makes it a different sort of mental exercise.
>>
>> So three is the magic number.
>
> I personally think that time is an interesting form of quantitative
> "special", and not a dimension as is simply because time exists in every
> dimension. Is that kind of, fair enough?

For instance, think of a 4d being looking into a 3d realm, and noticing
a clock hanging on a wall. Well, the 4d being can use the clock to sync
itself with the time in the 3d realm of that room that contains the
clock. Is this too out there? Sorry. ;^o

Re: Do you insist on const-correctness?

<uf2e6s$3arar$8@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29348&group=comp.lang.c#29348

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 16:34:52 -0700
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <uf2e6s$3arar$8@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf1s5c$37jjc$1@dont-email.me> <87il7vsbdn.fsf@nosuchdomain.example.com>
<uf1v7f$389r0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 23:34:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3501403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+c+Lf33nWccjb4WKwMeTMRJQl4dyRPhcY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:v6T/aGN7rKEuT/e5uNAKIFT4JjE=
Content-Language: en-US
In-Reply-To: <uf1v7f$389r0$1@dont-email.me>
 by: Chris M. Thomasson - Wed, 27 Sep 2023 23:34 UTC

On 9/27/2023 12:19 PM, David Brown wrote:
> On 27/09/2023 20:45, Keith Thompson wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 27/09/2023 19:46, Malcolm McLean wrote:
>> [...]
>>>> So three is the magic number.
>>>
>>> No.
>>>
>>> Seriously.  Just "no".
>> [...]
>>
>> David, do you think you're going to change his mind?
>>
>
> It seems unlikely, that's true.  I am afraid my tactics may have been
> inspired by watching too much Black Adder.

Watch some mr flibble to attempt to try to cool any overheated jets:

https://youtu.be/9-pnA0orMFU?t=67

;^)

(If anyone wants a break
> from discussing C, look up "Advanced World War I Tactics with General
> Melchett" on youtube.)
>
>> This discussion will end at some point without a resolution.
>> I suggest that now would be a good time for that.
>>
>
> You are almost certainly right.
>

Re: Do you insist on const-correctness?

<87il7vf96l.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29349&group=comp.lang.c#29349

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Thu, 28 Sep 2023 01:11:46 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <87il7vf96l.fsf@bsb.me.uk>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf1s5c$37jjc$1@dont-email.me>
<87il7vsbdn.fsf@nosuchdomain.example.com>
<uf1v7f$389r0$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="1432f0dee4a59f52e97231a9b3a0897f";
logging-data="3526827"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OaGZBEfMn+t0nHHu7QsHdrRicyZ1yyq4="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:a+UML8Phd4ugklh9nBeP+oYDJnA=
sha1:kQ3TGieLAUyAJibhkll1nlmQs6s=
X-BSB-Auth: 1.1cc3100afbf656995d1c.20230928011146BST.87il7vf96l.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 28 Sep 2023 00:11 UTC

David Brown <david.brown@hesbynett.no> writes:

> On 27/09/2023 20:45, Keith Thompson wrote:
>> David Brown <david.brown@hesbynett.no> writes:
>>> On 27/09/2023 19:46, Malcolm McLean wrote:
>> [...]
>>>> So three is the magic number.
>>>
>>> No.
>>>
>>> Seriously. Just "no".
>> [...]
>> David, do you think you're going to change his mind?
>
> It seems unlikely, that's true.

Also, does it matter? It's not as if a rule has been put forward with
such detail that someone new to C will come across the post and feel
they must alter the way they write code to follow it.

These things wind me up as well, but I just hit 'n' and I am all the
happier for it!

--
Ben.

Re: Do you insist on const-correctness?

<ae6164a3-b59c-4b5f-b3f7-30e9ff1a9eban@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29350&group=comp.lang.c#29350

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:41c:b0:774:ced:d378 with SMTP id 28-20020a05620a041c00b007740cedd378mr39304qkp.9.1695859928318;
Wed, 27 Sep 2023 17:12:08 -0700 (PDT)
X-Received: by 2002:a05:6808:1a0d:b0:3a7:3737:60fd with SMTP id
bk13-20020a0568081a0d00b003a7373760fdmr1582316oib.7.1695859928135; Wed, 27
Sep 2023 17:12:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Wed, 27 Sep 2023 17:12:07 -0700 (PDT)
In-Reply-To: <uf1sfp$37m2f$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:f919:d1df:b42:2927;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:f919:d1df:b42:2927
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com> <20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me> <20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc> <ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com> <uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com> <uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com> <uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com> <uf1sfp$37m2f$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ae6164a3-b59c-4b5f-b3f7-30e9ff1a9eban@googlegroups.com>
Subject: Re: Do you insist on const-correctness?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 28 Sep 2023 00:12:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 70
 by: Malcolm McLean - Thu, 28 Sep 2023 00:12 UTC

On Wednesday, 27 September 2023 at 19:32:40 UTC+1, Bart wrote:
> On 27/09/2023 18:46, Malcolm McLean wrote:
> > On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
> >> On 27/09/2023 17:35, Malcolm McLean wrote:
> >>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
> >>>> On 27/09/2023 12:37, Malcolm McLean wrote:
> >>>>
> >>>>> (Nesting, indirection, and dimensioning are all related to each other).
> >>>> No, they are not.
> >>>>
> >>> You haven't thought this through, have you?
> >> Yes, I have.
> >>
> >> I mean, obviously if you want to have an n-dimensional array and loop
> >> through it all, you'll have n levels of nesting, and your array access
> >> is technically through pointers with n levels of indirection.
> >>
> > Exactly. Not exactly a controversial idea, is it?
> > Nesting, indirection, and dimensioning are all related to each other.
> > And we can visualise three dimensions easily enough, because we live
> > in a world with three dimensions of space. To visualise four dimensions,
> > you have to add time, which makes it a different sort of mental exercise.
> >
> > So three is the magic number.
> I don't think it works. Computer source code is usually 2-dimensional,
> tends to be limited horizontally, but has no particular limits vertically.
>
> The code unit is the 'function', which are not usually that tall, as
> they become unmanageable, and are not that wide either as people don't
> like scrolling sideways. That's why text like this wraps onto the next
> line, but that doesn't work for code which is line- not paragraph-oriented.
>
> When talking about function nesting, my own magic number is 1, and
> standard C doesn't allow more anyway. So people are welcome to limit
> those to three, as I don't care!
>
> But imagine applying the 'rule of three' to:
>
> - The number of lines in a function
>
> - The number of functions in a module
>
> - The number of modules in a program
>
> - The number of fields in a struct
>
> It doesn't work, does it? Or is this more about nesting?
>
> Was there also something about the number of nested parentheses in an
> expression? You don't really need a rule, as it will be obvious when
> there are far too many.
>
If C allowed for nested functions then it would start to become hard for
programmers to understand when the nesting level exceeded three.

But the rule of three doesn't apply to metrics which don't bear a relationship
to dimensions, like the number of lines in a function, or the number of
fields in a struct. Here there may be other psychological limits, but they
arise from different underlying causes.

The rule of three does apply to parentheses. Here you can easily verify
it. Simply write some expressions and note when the nesting starts to
make understanding the expression harder rather than easier.

Nesting has hierarchy whilst dimensions don't. And nesting doesn't have to
be balanced, but nesting which represents a multi-dimensional array
does have to be balanced. So it's related but not exactly the same thing (I
really shouldn't have to make this simple point, however I do). You can't
visualise a four-dimensional structure in your mind, and you can't take
in more than three levels of nesting without consciously matching either.

Re: Do you insist on const-correctness?

<87cyy3f858.fsf@bsb.me.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29352&group=comp.lang.c#29352

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Thu, 28 Sep 2023 01:34:11 +0100
Organization: A noiseless patient Spider
Lines: 61
Message-ID: <87cyy3f858.fsf@bsb.me.uk>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me> <ueuv1r$2iped$1@dont-email.me>
<20230926093309.110@kylheku.com> <uev5e6$2k5cd$1@dont-email.me>
<uf0t4p$314n3$1@dont-email.me> <uf17dn$33109$1@dont-email.me>
<uf1n3q$36bge$2@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="1432f0dee4a59f52e97231a9b3a0897f";
logging-data="3533671"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18kWiArMZd5KH/mW+ii6Ei12Q9WgSM8UOI="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:A50P9lMcqxPzJL77k+6+XlgzJAA=
sha1:+jYwSC9ZAclz0TVx+YXO8E4g/eg=
X-BSB-Auth: 1.81ae3f20b5643221dfa0.20230928013411BST.87cyy3f858.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 28 Sep 2023 00:34 UTC

David Brown <david.brown@hesbynett.no> writes:

> On 27/09/2023 14:32, Bart wrote:
>> On 27/09/2023 10:37, David Brown wrote:
>>
>>> I will even write something like this on occasion :
>>>
>>>      if (<complicated condition>) {
>>>          // Everything is fine, nothing to do
>>>      } else {
>>>          do_something();
>>>      }
>>>
>>> rather than
>>>
>>>      if (!(<complicated condition>)) {
>>>          do_something();
>>>      }
>>>
>>> It is all about what is clearest to read.
>> I have a version of 'if' called 'unless', which sometimes reads better,
>> but not always.
>> In particular, although 'unless' can have an 'else' branch, it doesn't
>> have 'else-unless'; I couldn't work out what it meant!
>
> There are a few different varieties of conditionals that have been tried in
> different programming languages. That includes syntaxes roughly like "x =
> x - 1 if x > 0", or FORTH's "x ? 0 > if x ? 1 - x ! then", if I have
> remembered the details correctly. I don't think it really helps to have
> too many ways of doing the same thing - there has to be very clear gains to
> make it worth the effort.

The biggest departure are multi-way ifs like

if C1 -> S1
C2 -> S2
...
fi

I've even come across a language where the while loop had the same
structure with do ... od in place of if .. fi. For example

do a > b -> a :=: b
b > c -> b :=: c
od

where :=: is a swap operator ensures that the values in a, b and c are
in non-decreasing order.

One variation (I think it was used in S-Algol) is to have a case
statement where the arms can have arbitrary expressions. A multi-way
if then looks like this:

case true of
x > 0: return +1
x == 0: return 0
x < 0: return -1
esac

--
Ben.

Re: Do you insist on const-correctness?

<uf2ije$3bv1r$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29354&group=comp.lang.c#29354

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Thu, 28 Sep 2023 01:49:51 +0100
Organization: A noiseless patient Spider
Lines: 97
Message-ID: <uf2ije$3bv1r$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf1sfp$37m2f$1@dont-email.me>
<ae6164a3-b59c-4b5f-b3f7-30e9ff1a9eban@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 28 Sep 2023 00:49:50 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1ef586021a048bc23a8e58600ba293f6";
logging-data="3537979"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MIoU8ph4Vc1vVlwi1rUNHzvOcj1qEQ4c="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:uH1P1x1z08EA0cjRGSmaWZJM4cI=
In-Reply-To: <ae6164a3-b59c-4b5f-b3f7-30e9ff1a9eban@googlegroups.com>
 by: Bart - Thu, 28 Sep 2023 00:49 UTC

On 28/09/2023 01:12, Malcolm McLean wrote:
> On Wednesday, 27 September 2023 at 19:32:40 UTC+1, Bart wrote:
>> On 27/09/2023 18:46, Malcolm McLean wrote:
>>> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>>>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>>>
>>>>>>> (Nesting, indirection, and dimensioning are all related to each other).
>>>>>> No, they are not.
>>>>>>
>>>>> You haven't thought this through, have you?
>>>> Yes, I have.
>>>>
>>>> I mean, obviously if you want to have an n-dimensional array and loop
>>>> through it all, you'll have n levels of nesting, and your array access
>>>> is technically through pointers with n levels of indirection.
>>>>
>>> Exactly. Not exactly a controversial idea, is it?
>>> Nesting, indirection, and dimensioning are all related to each other.
>>> And we can visualise three dimensions easily enough, because we live
>>> in a world with three dimensions of space. To visualise four dimensions,
>>> you have to add time, which makes it a different sort of mental exercise.
>>>
>>> So three is the magic number.
>> I don't think it works. Computer source code is usually 2-dimensional,
>> tends to be limited horizontally, but has no particular limits vertically.
>>
>> The code unit is the 'function', which are not usually that tall, as
>> they become unmanageable, and are not that wide either as people don't
>> like scrolling sideways. That's why text like this wraps onto the next
>> line, but that doesn't work for code which is line- not paragraph-oriented.
>>
>> When talking about function nesting, my own magic number is 1, and
>> standard C doesn't allow more anyway. So people are welcome to limit
>> those to three, as I don't care!
>>
>> But imagine applying the 'rule of three' to:
>>
>> - The number of lines in a function
>>
>> - The number of functions in a module
>>
>> - The number of modules in a program
>>
>> - The number of fields in a struct
>>
>> It doesn't work, does it? Or is this more about nesting?
>>
>> Was there also something about the number of nested parentheses in an
>> expression? You don't really need a rule, as it will be obvious when
>> there are far too many.
>>
> If C allowed for nested functions then it would start to become hard for
> programmers to understand when the nesting level exceeded three.
>
> But the rule of three doesn't apply to metrics which don't bear a relationship
> to dimensions, like the number of lines in a function, or the number of
> fields in a struct. Here there may be other psychological limits, but they
> arise from different underlying causes.
>
> The rule of three does apply to parentheses. Here you can easily verify
> it. Simply write some expressions and note when the nesting starts to
> make understanding the expression harder rather than easier.
>
> Nesting has hierarchy whilst dimensions don't. And nesting doesn't have to
> be balanced, but nesting which represents a multi-dimensional array
> does have to be balanced. So it's related but not exactly the same thing (I
> really shouldn't have to make this simple point, however I do). You can't
> visualise a four-dimensional structure in your mind, and you can't take
> in more than three levels of nesting without consciously matching either.

No, 4 spatial dimensions is entirely different because we are only
familiar with 3. (Although could probably cope with projections of 4
into 3.)

But nesting levels are like Russian dolls; we can easily visualise half
dozen.

I've done a quick survey of my own codebase; maximum nesting, not
including functions and modules or any encapsulating type, is 6,
although that's unusual.

It's not a problem, because you don't need to 'get' the whole thing. If
you already have 4 levels, then the code at that 4th level needs:

if a then b else c

that is perfectly clear in that local context. It doesn't need relating
to all the outer levels. And within that new 5th level, you may have an
expression with parentheses; should those be added in too, or considered
separate? If the latter, than that's what happens with statement levels.

(BTW here is that 6-level chunk of a function:

https://github.com/sal55/langs/blob/master/nesting.m)

Re: Do you insist on const-correctness?

<uf2iqj$3bu8j$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29355&group=comp.lang.c#29355

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Wed, 27 Sep 2023 17:53:39 -0700
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <uf2iqj$3bu8j$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf1sfp$37m2f$1@dont-email.me>
<ae6164a3-b59c-4b5f-b3f7-30e9ff1a9eban@googlegroups.com>
<uf2ije$3bv1r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 28 Sep 2023 00:53:40 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="c1df78dddbfa39390bab69519cc4186e";
logging-data="3537171"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k3ppdf42FVPPNAq9lSB5lx0JIiN8UnWo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:KaTgmClVWEtx0YQWz+YlLUX1Xsg=
In-Reply-To: <uf2ije$3bv1r$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 28 Sep 2023 00:53 UTC

On 9/27/2023 5:49 PM, Bart wrote:
> On 28/09/2023 01:12, Malcolm McLean wrote:
>> On Wednesday, 27 September 2023 at 19:32:40 UTC+1, Bart wrote:
>>> On 27/09/2023 18:46, Malcolm McLean wrote:
>>>> On Wednesday, 27 September 2023 at 17:53:10 UTC+1, David Brown wrote:
>>>>> On 27/09/2023 17:35, Malcolm McLean wrote:
>>>>>> On Wednesday, 27 September 2023 at 16:03:35 UTC+1, David Brown wrote:
>>>>>>> On 27/09/2023 12:37, Malcolm McLean wrote:
>>>>>>>
>>>>>>>> (Nesting, indirection, and dimensioning are all related to each
>>>>>>>> other).
>>>>>>> No, they are not.
>>>>>>>
>>>>>> You haven't thought this through, have you?
>>>>> Yes, I have.
>>>>>
>>>>> I mean, obviously if you want to have an n-dimensional array and loop
>>>>> through it all, you'll have n levels of nesting, and your array access
>>>>> is technically through pointers with n levels of indirection.
>>>>>
>>>> Exactly. Not exactly a controversial idea, is it?
>>>> Nesting, indirection, and dimensioning are all related to each other.
>>>> And we can visualise three dimensions easily enough, because we live
>>>> in a world with three dimensions of space. To visualise four
>>>> dimensions,
>>>> you have to add time, which makes it a different sort of mental
>>>> exercise.
>>>>
>>>> So three is the magic number.
>>> I don't think it works. Computer source code is usually 2-dimensional,
>>> tends to be limited horizontally, but has no particular limits
>>> vertically.
>>>
>>> The code unit is the 'function', which are not usually that tall, as
>>> they become unmanageable, and are not that wide either as people don't
>>> like scrolling sideways. That's why text like this wraps onto the next
>>> line, but that doesn't work for code which is line- not
>>> paragraph-oriented.
>>>
>>> When talking about function nesting, my own magic number is 1, and
>>> standard C doesn't allow more anyway. So people are welcome to limit
>>> those to three, as I don't care!
>>>
>>> But imagine applying the 'rule of three' to:
>>>
>>> - The number of lines in a function
>>>
>>> - The number of functions in a module
>>>
>>> - The number of modules in a program
>>>
>>> - The number of fields in a struct
>>>
>>> It doesn't work, does it? Or is this more about nesting?
>>>
>>> Was there also something about the number of nested parentheses in an
>>> expression? You don't really need a rule, as it will be obvious when
>>> there are far too many.
>>>
>> If C allowed for nested functions then it would start to become hard for
>> programmers to understand when the nesting level exceeded three.
>>
>> But the rule of three doesn't apply to metrics which don't bear a
>> relationship
>> to dimensions, like the number of lines in a function, or the number of
>> fields in a struct. Here there may be other psychological limits, but
>> they
>> arise from different underlying causes.
>>
>> The rule of three does apply to parentheses. Here you can easily verify
>> it. Simply write some expressions and note when the nesting starts to
>> make understanding the expression harder rather than easier.
>>
>> Nesting has hierarchy whilst dimensions don't. And nesting doesn't
>> have to
>> be balanced, but nesting which represents a multi-dimensional array
>> does have to be balanced. So it's related but not exactly the same
>> thing (I
>> really shouldn't have to make this simple point, however I do).  You
>> can't
>> visualise a four-dimensional structure in your mind, and you can't take
>> in more than three levels of nesting without consciously matching either.
>
> No, 4 spatial dimensions is entirely different because we are only
> familiar with 3. (Although could probably cope with projections of 4
> into 3.)
>
> But nesting levels are like Russian dolls; we can easily visualise half
> dozen.[...]
Think of using a 4'th component to be able to see through things. An
alpha channel for a color, for instance.

Re: Do you insist on const-correctness?

<uf3c9n$3jdkk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29359&group=comp.lang.c#29359

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Thu, 28 Sep 2023 10:08:23 +0200
Organization: A noiseless patient Spider
Lines: 92
Message-ID: <uf3c9n$3jdkk$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me> <ueuv1r$2iped$1@dont-email.me>
<20230926093309.110@kylheku.com> <uev5e6$2k5cd$1@dont-email.me>
<uf0t4p$314n3$1@dont-email.me> <uf17dn$33109$1@dont-email.me>
<uf1n3q$36bge$2@dont-email.me> <87cyy3f858.fsf@bsb.me.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 28 Sep 2023 08:08:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="56cfb1e42eeee6c2336adac75ef6e5b7";
logging-data="3782292"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QlRvxpweD0uAlfvHItTG2PtERuidnhR0="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:lwkpWNL8FZfyVvckU42ZmBOUc8U=
Content-Language: en-GB
In-Reply-To: <87cyy3f858.fsf@bsb.me.uk>
 by: David Brown - Thu, 28 Sep 2023 08:08 UTC

On 28/09/2023 02:34, Ben Bacarisse wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> On 27/09/2023 14:32, Bart wrote:
>>> On 27/09/2023 10:37, David Brown wrote:
>>>
>>>> I will even write something like this on occasion :
>>>>
>>>>      if (<complicated condition>) {
>>>>          // Everything is fine, nothing to do
>>>>      } else {
>>>>          do_something();
>>>>      }
>>>>
>>>> rather than
>>>>
>>>>      if (!(<complicated condition>)) {
>>>>          do_something();
>>>>      }
>>>>
>>>> It is all about what is clearest to read.
>>> I have a version of 'if' called 'unless', which sometimes reads better,
>>> but not always.
>>> In particular, although 'unless' can have an 'else' branch, it doesn't
>>> have 'else-unless'; I couldn't work out what it meant!
>>
>> There are a few different varieties of conditionals that have been tried in
>> different programming languages. That includes syntaxes roughly like "x =
>> x - 1 if x > 0", or FORTH's "x ? 0 > if x ? 1 - x ! then", if I have
>> remembered the details correctly. I don't think it really helps to have
>> too many ways of doing the same thing - there has to be very clear gains to
>> make it worth the effort.
>
> The biggest departure are multi-way ifs like
>
> if C1 -> S1
> C2 -> S2
> ...
> fi

Yes, especially if the choice is non-deterministic (that is, if the C2
and C3 are both true, then one of S2 or S3 will happen, but you don't
control which). That would probably surprise many programmers of
traditional languages, but I can see it having clear benefits. For
example, an "abs" function could be :

if x >= 0 -> return x;
x <= 0 -> return -x;
fi

Then it's up to the compiler to figure out the most efficient way to
make the code, using either return path in the case x == 0.

I can't think off-hand of a language that supports such overlapping
cases in that way. (Of course compilers can always do things like that
when following the "as if" rule.)

>
> I've even come across a language where the while loop had the same
> structure with do ... od in place of if .. fi. For example
>
> do a > b -> a :=: b
> b > c -> b :=: c
> od
>
> where :=: is a swap operator ensures that the values in a, b and c are
> in non-decreasing order.
>
> One variation (I think it was used in S-Algol) is to have a case
> statement where the arms can have arbitrary expressions. A multi-way
> if then looks like this:
>
> case true of
> x > 0: return +1
> x == 0: return 0
> x < 0: return -1
> esac
>

Is that really much different from :

if (x > 0) return -1;
if (x == 0) return 0;
if (x < 0) return -1;

?

Re: Do you insist on const-correctness?

<uf3hhh$3kcto$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29360&group=comp.lang.c#29360

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Thu, 28 Sep 2023 10:37:54 +0100
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <uf3hhh$3kcto$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me> <ueuv1r$2iped$1@dont-email.me>
<20230926093309.110@kylheku.com> <uev5e6$2k5cd$1@dont-email.me>
<uf0t4p$314n3$1@dont-email.me> <uf17dn$33109$1@dont-email.me>
<uf1n3q$36bge$2@dont-email.me> <87cyy3f858.fsf@bsb.me.uk>
<uf3c9n$3jdkk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 28 Sep 2023 09:37:53 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1ef586021a048bc23a8e58600ba293f6";
logging-data="3814328"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NCZOerL05A5s860Hz9jtToBBtHHmNE84="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:vU8jgSFsIVpTfKDYVtLjacvYrp4=
In-Reply-To: <uf3c9n$3jdkk$1@dont-email.me>
 by: Bart - Thu, 28 Sep 2023 09:37 UTC

On 28/09/2023 09:08, David Brown wrote:
> On 28/09/2023 02:34, Ben Bacarisse wrote:

>> One variation (I think it was used in S-Algol) is to have a case
>> statement where the arms can have arbitrary expressions.  A multi-way
>> if then looks like this:
>>
>>    case true of
>>      x  > 0: return +1
>>      x == 0: return  0
>>      x  < 0: return -1
>>    esac
>>
>
> Is that really much different from :
>
>     if (x > 0) return -1;
>     if (x == 0) return 0;
>     if (x < 0) return -1;
>
> ?

Yes, it's all encapsulated within one construct. With the separate ifs,
you add arbitrary statements between then, which is likely not possible
with the case.

Also, if you were to have something other then a return for 'x==0', the
case probably wouldn't fall through to the x<0 test, but it will do for
the ifs.

Further (I don't know if that is the case for that language, but it is
for mine), you might be able to write the case version like this:

return case true of
x > 0: +1
x == 0: 0
x < 0: -1
esac

or even leave out the 'return' completely if this is last statement in a
function. With the ifs, only the third 'if' is the last statement.

In short, the case is properly structured. The 'if' version is more like
early Fortran.

Re: Do you insist on const-correctness?

<uf3k3r$3ku97$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29361&group=comp.lang.c#29361

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Thu, 28 Sep 2023 11:21:48 +0100
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <uf3k3r$3ku97$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me>
<499dbc5e-44f7-45a6-bb0b-69ec6933d0a6n@googlegroups.com>
<uf0r7l$30kt2$1@dont-email.me>
<2aa534e2-1567-43d5-9f36-7c4266e3b9e1n@googlegroups.com>
<uf1g7o$34tu1$1@dont-email.me>
<bb817356-d077-49c2-8bf4-c3f9774aabffn@googlegroups.com>
<uf1ml5$36bge$1@dont-email.me>
<03fb354b-016a-4451-887b-27dfa6c56f56n@googlegroups.com>
<uf1sfp$37m2f$1@dont-email.me>
<ae6164a3-b59c-4b5f-b3f7-30e9ff1a9eban@googlegroups.com>
<uf2ije$3bv1r$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 28 Sep 2023 10:21:47 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="1ef586021a048bc23a8e58600ba293f6";
logging-data="3832103"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WmOeDNYK+hLw7aYFl2z1e2VHrMwvvtdI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Cancel-Lock: sha1:TDTBaHOcIku436wUICce90/rS8c=
In-Reply-To: <uf2ije$3bv1r$1@dont-email.me>
 by: Bart - Thu, 28 Sep 2023 10:21 UTC

On 28/09/2023 01:49, Bart wrote:
> On 28/09/2023 01:12, Malcolm McLean wrote:

>> Nesting has hierarchy whilst dimensions don't. And nesting doesn't
>> have to
>> be balanced, but nesting which represents a multi-dimensional array
>> does have to be balanced. So it's related but not exactly the same
>> thing (I
>> really shouldn't have to make this simple point, however I do).  You
>> can't
>> visualise a four-dimensional structure in your mind, and you can't take
>> in more than three levels of nesting without consciously matching either.

> I've done a quick survey of my own codebase; maximum nesting, not
> including functions and modules or any encapsulating type, is 6,
> although that's unusual.

> (BTW here is that 6-level chunk of a function:
>
> https://github.com/sal55/langs/blob/master/nesting.m)

Looking at line 20 of this extract, there is 'else' followed by 'case'
(and the only statement in that branch) which is a candidate for my
'elsecase' feature. That would reduce nesting and indents by one level
(and removes one block-terminating keyword).

Actually, the C idiom to emulate if-elseif: 'if else if else ...' would
normally involve N nesting levels, except that people ignore that and
use fixed indentation.

But the point is, it's not an extra cognitive load, because the
structure is perceived as flat, not nested.

Re: Do you insist on const-correctness?

<uf3qkq$3m38j$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=29363&group=comp.lang.c#29363

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Do you insist on const-correctness?
Date: Thu, 28 Sep 2023 14:13:14 +0200
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <uf3qkq$3m38j$1@dont-email.me>
References: <20230918012105.b9fb2c36e93542dddb654b1f@gmail.moc>
<86a5tkmj1b.fsf@linuxsc.com>
<20230918115357.0c06b3c4225a6c33bb3244dc@g{oogle}mail.com>
<ue9ocg$1qfvq$1@dont-email.me>
<20230923190523.1f810ae96368b345fe455268@gmail.moc>
<uera6l$1pr35$1@dont-email.me> <ueronc$1sd54$1@dont-email.me>
<ues2jo$1uh7s$1@dont-email.me> <ueshl5$21lmm$1@dont-email.me>
<uesi26$21hbl$7@dont-email.me> <ueskug$22af7$1@dont-email.me>
<20230926143726.8fd502c51264c4e127203da4@gmail.moc>
<ueus9s$2ibi2$1@dont-email.me> <ueuv1r$2iped$1@dont-email.me>
<20230926093309.110@kylheku.com> <uev5e6$2k5cd$1@dont-email.me>
<uf0t4p$314n3$1@dont-email.me> <uf17dn$33109$1@dont-email.me>
<uf1n3q$36bge$2@dont-email.me> <87cyy3f858.fsf@bsb.me.uk>
<uf3c9n$3jdkk$1@dont-email.me> <uf3hhh$3kcto$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 28 Sep 2023 12:13:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="56cfb1e42eeee6c2336adac75ef6e5b7";
logging-data="3869971"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+aYe1ngUu6AkG9106b9liVsrZlP+prZPE="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:IPJh7V0rzaaLS9XPRpqr6Ubo2fI=
Content-Language: en-GB
In-Reply-To: <uf3hhh$3kcto$1@dont-email.me>
 by: David Brown - Thu, 28 Sep 2023 12:13 UTC

On 28/09/2023 11:37, Bart wrote:
> On 28/09/2023 09:08, David Brown wrote:
>> On 28/09/2023 02:34, Ben Bacarisse wrote:
>
>>> One variation (I think it was used in S-Algol) is to have a case
>>> statement where the arms can have arbitrary expressions.  A multi-way
>>> if then looks like this:
>>>
>>>    case true of
>>>      x  > 0: return +1
>>>      x == 0: return  0
>>>      x  < 0: return -1
>>>    esac
>>>
>>
>> Is that really much different from :
>>
>>      if (x > 0) return -1;
>>      if (x == 0) return 0;
>>      if (x < 0) return -1;
>>
>> ?
>
> Yes, it's all encapsulated within one construct. With the separate ifs,
> you add arbitrary statements between then, which is likely not possible
> with the case.

That's true. But is there a semantic difference, when there are no
arbitrary statements between them? (I'm a fan of constructs that have
limits on what they allow, so I can see a point in such as "case"
statement even if the meanings are the same.)

>
> Also, if you were to have something other then a return for 'x==0', the
> case probably wouldn't fall through to the x<0 test, but it will do for
> the ifs.

Yes, but that makes no difference in this situation. (It would make a
difference if there were overlaps in the conditionals, or if the
conditionals had side-effects.)

>
> Further (I don't know if that is the case for that language, but it is
> for mine), you might be able to write the case version like this:
>
>     return case true of
>            x  > 0: +1
>            x == 0:  0
>            x  < 0: -1
>            esac
>
> or even leave out the 'return' completely if this is last statement in a
> function. With the ifs, only the third 'if' is the last statement.
>
> In short, the case is properly structured. The 'if' version is more like
> early Fortran.
>


devel / comp.lang.c / Re: Do you insist on const-correctness?

Pages:12345678
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor