Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Just think, with VLSI we can have 100 ENIACS on a chip!" -- Alan Perlis


devel / comp.lang.c / Re: Linus Torvalds prepares to move the Linux kernel to modern C

SubjectAuthor
* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
+* Re: Linus Torvalds prepares to move the Linux kernel to modern CLynn McGuire
|+* Re: Linus Torvalds prepares to move the Linux kernel to modern Crthiebaud
||`* Re: Linus Torvalds prepares to move the Linux kernel to modern CLynn McGuire
|| +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
|| +* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
|| |`* Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
|| | `* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
|| |  `* Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
|| |   +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
|| |   `- Re: Linus Torvalds prepares to move the Linux kernel to modern CVir Campestris
|| `- Re: Linus Torvalds prepares to move the Linux kernel to modern CScott Lurndal
|+* Re: Linus Torvalds prepares to move the Linux kernel to modern CKaz Kylheku
||`* Re: Linus Torvalds prepares to move the Linux kernel to modern CLynn McGuire
|| `- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
|+- Re: Linus Torvalds prepares to move the Linux kernel to modern CManu Raju
|`- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
+* Re: Linus Torvalds prepares to move the Linux kernel to modern CLynn McGuire
|`* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| +* Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| |+* Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||`- Re: Linus Torvalds prepares to move the Linux kernel to modern CManfred
| |+- Re: Linus Torvalds prepares to move the Linux kernel to modern CScott Lurndal
| |`- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| +* Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| |+* Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||`* Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| || +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| || +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| || +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| || `* Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
| ||  `* Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||   +* Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| ||   |+- Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||   |`* Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||   | +* Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||   | |`* Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||   | | `* Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||   | |  `- Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||   | `* Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
| ||   |  +* Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||   |  |`- Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
| ||   |  `* Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||   |   `* Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
| ||   |    `- Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||   `* Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
| ||    `* Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse
| ||     `- Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
| |+* Re: Linus Torvalds prepares to move the Linux kernel to modern Crthiebaud
| ||`* Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| || +* Re: Linus Torvalds prepares to move the Linux kernel to modern CLynn McGuire
| || |+- Re: Linus Torvalds prepares to move the Linux kernel to modern CGary R. Schmidt
| || |`- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| || `* Re: Linus Torvalds prepares to move the Linux kernel to modern CManfred
| ||  +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| ||  +* Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| ||  |`* Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||  | `- Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| ||  `* Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||   +- Re: Linus Torvalds prepares to move the Linux kernel to modern CManfred
| ||   `* Re: Linus Torvalds prepares to move the Linux kernel to modern CLew Pitcher
| ||    +* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| ||    |`* Re: Linus Torvalds prepares to move the Linux kernel to modern CScott Lurndal
| ||    | `* Re: Linus Torvalds prepares to move the Linux kernel to modern CKeith Thompson
| ||    |  `* Re: Linus Torvalds prepares to move the Linux kernel to modern CScott Lurndal
| ||    |   +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| ||    |   `* Re: Linus Torvalds prepares to move the Linux kernel to modern CKeith Thompson
| ||    |    `* Re: Linus Torvalds prepares to move the Linux kernel to modern CScott Lurndal
| ||    |     `- Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||    +- Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| ||    `* Re: Linus Torvalds prepares to move the Linux kernel to modern CVir Campestris
| ||     +- Re: Linus Torvalds prepares to move the Linux kernel to modern CMalcolm McLean
| ||     `* Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| ||      `* Re: Linus Torvalds prepares to move the Linux kernel to modern CDavid Brown
| ||       `- Re: Linus Torvalds prepares to move the Linux kernel to modern CBart
| |`- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
| `* Re: Linus Torvalds prepares to move the Linux kernel to modern CScott Lurndal
|  +* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
|  |`* Re: Linus Torvalds prepares to move the Linux kernel to modern CScott Lurndal
|  | `* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
|  |  `- Re: Linus Torvalds prepares to move the Linux kernel to modern CChris M. Thomasson
|  `- Re: Linus Torvalds prepares to move the Linux kernel to modern CTim Rentsch
`* Re: Linus Torvalds prepares to move the Linux kernel to modern CChris M. Thomasson
 +* Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
 |`* Re: Linus Torvalds prepares to move the Linux kernel to modern CChris M. Thomasson
 | `- Re: Linus Torvalds prepares to move the Linux kernel to modern CBonita Montero
 `- Re: Linus Torvalds prepares to move the Linux kernel to modern CBen Bacarisse

Pages:1234
Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svqkg5$q1i$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 14:48:37 +0000
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <svqkg5$q1i$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 3 Mar 2022 14:48:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cdd9ae9ac835544bf069b74349a5db5b";
logging-data="26674"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IoBHXnllb4nHVh8regJUxN0FKT+zPtPo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:GGiCzpyEZxq15qTxZDDAGwxND14=
In-Reply-To: <svqi6n$1ccc$1@gioia.aioe.org>
 by: Bart - Thu, 3 Mar 2022 14:48 UTC

On 03/03/2022 14:09, Manfred wrote:
> On 3/2/2022 8:19 PM, Bart wrote:
>> On 02/03/2022 18:06, rthiebaud wrote:
>>>>>>>> standard.
>>>>>>>>
>>>> * Whole-program compilers
>>>> * 64-bit everything (C is still stuck on 32-bits)
>>>> * Super-fast compilers ...
>>>   Who says
>>> C is stuck is 32 bits?
>>
>> It just is. While versions with 64-bit ints might be knocking about,
>> generally they have to be compatible with what C already does on a
>> given platform. And that usually means int = 32 bits.
>>
>> So, while people can choose to use long long int or int64_t, they have
>> to explicity state that everywhere, because:
>>
>>    12345          is int32
>>    'A'            is int32
>>    short a,b,c;
>>       a*b*c       is int32 (so could overflow)
>>    %d             means int32 format
>>    sprintf        returns int32
>>    f(){}          defaults to int32 return type
>>    int64_t a,b;
>>    a && b         is int32
>>    !a             is int32
>>    enum E {a=5000000000};
>>    enum E xx;     is int32 (int64 on some compilers with extensions)
>>
>> etc
>
> Are you seriously suggesting that the default size of int should be 64
> bits everywhere?
> Even for a general purpose counter from 1 to 10?

As BM said, even int32 is overkill in that case.

But what exactly is the problem? Most desktop PCs use 64-bit processors;
I'd guess most phones and other consumer kit does as well.

They will already have 64-bit registers, 64-bit stack slots, 64-bit
addresses and will be using 64-bit floats.

There's little advantage in having standalone int variables, parameters
and return types being 32 bits. (For parameters, each will use a 64-bit
register or stack slot anyway, and the return value will be in a 64-bit
register.) Pointers of course will already be 64 bits.

Sure, for arrays and structs, then you can choose narrower types if you
want, since they can otherwise use twice as much memory, but not as a
default type.

You want to be able to write 1<<40 without remembering to do 1LL<<40,
and to more or less forget about integer overflows in calculations,
since int64 has a numeric range 4 billion times wider than int32.

Int64 also covers the ranges of all u8 to u32 types.

You can also write %d as a format, without wondering whether it's %ld or
%lld or PRId64 or whatever.

(I've developed and used languages with a 64-bit type for a decade, and
it is a joy.)

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:5a91:0:b0:2de:25c5:1d68 with SMTP id c17-20020ac85a91000000b002de25c51d68mr27660463qtc.94.1646320795657;
Thu, 03 Mar 2022 07:19:55 -0800 (PST)
X-Received: by 2002:a05:620a:a82:b0:508:b41b:c44b with SMTP id
v2-20020a05620a0a8200b00508b41bc44bmr19266680qkg.100.1646320795528; Thu, 03
Mar 2022 07:19:55 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.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: Thu, 3 Mar 2022 07:19:55 -0800 (PST)
In-Reply-To: <svqi6n$1ccc$1@gioia.aioe.org>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:1d61:9d25:ba5e:a87;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:1d61:9d25:ba5e:a87
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me> <svmsrh$6j9$1@dont-email.me>
<svnsgk$b0g$1@dont-email.me> <svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 03 Mar 2022 15:19:55 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 10
 by: Malcolm McLean - Thu, 3 Mar 2022 15:19 UTC

On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
> On 3/2/2022 8:19 PM, Bart wrote:
>
> Are you seriously suggesting that the default size of int should be 64
> bits everywhere?
> Even for a general purpose counter from 1 to 10?
>
The vast majority of integers are small. But there's a lot to be said for
having one integer type which is used everywhere there isn't a strong
case against, which can count any collection of objects in the computer's
memory, and which is called "int".

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<af49fea8-d5bf-43f1-88df-09393bf1835cn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:2238:b0:663:76fa:7bbf with SMTP id n24-20020a05620a223800b0066376fa7bbfmr3392011qkh.48.1646321541548;
Thu, 03 Mar 2022 07:32:21 -0800 (PST)
X-Received: by 2002:a05:622a:174b:b0:2e0:390d:1e98 with SMTP id
l11-20020a05622a174b00b002e0390d1e98mr6405354qtk.529.1646321541392; Thu, 03
Mar 2022 07:32:21 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.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: Thu, 3 Mar 2022 07:32:21 -0800 (PST)
In-Reply-To: <svqkg5$q1i$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:1d61:9d25:ba5e:a87;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:1d61:9d25:ba5e:a87
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me> <svmsrh$6j9$1@dont-email.me>
<svnsgk$b0g$1@dont-email.me> <svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org> <svqkg5$q1i$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <af49fea8-d5bf-43f1-88df-09393bf1835cn@googlegroups.com>
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 03 Mar 2022 15:32:21 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 56
 by: Malcolm McLean - Thu, 3 Mar 2022 15:32 UTC

On Thursday, 3 March 2022 at 14:49:14 UTC, Bart wrote:
> On 03/03/2022 14:09, Manfred wrote:
> > On 3/2/2022 8:19 PM, Bart wrote:
> >> On 02/03/2022 18:06, rthiebaud wrote:
> >>>>>>>> standard.
> >>>>>>>>
> >>>> * Whole-program compilers
> >>>> * 64-bit everything (C is still stuck on 32-bits)
> >>>> * Super-fast compilers ...
> >>> Who says
> >>> C is stuck is 32 bits?
> >>
> >> It just is. While versions with 64-bit ints might be knocking about,
> >> generally they have to be compatible with what C already does on a
> >> given platform. And that usually means int = 32 bits.
> >>
> >> So, while people can choose to use long long int or int64_t, they have
> >> to explicity state that everywhere, because:
> >>
> >> 12345 is int32
> >> 'A' is int32
> >> short a,b,c;
> >> a*b*c is int32 (so could overflow)
> >> %d means int32 format
> >> sprintf returns int32
> >> f(){} defaults to int32 return type
> >> int64_t a,b;
> >> a && b is int32
> >> !a is int32
> >> enum E {a=5000000000};
> >> enum E xx; is int32 (int64 on some compilers with extensions)
> >>
> >> etc
> >
> > Are you seriously suggesting that the default size of int should be 64
> > bits everywhere?
> > Even for a general purpose counter from 1 to 10?
> As BM said, even int32 is overkill in that case.
>
> But what exactly is the problem? Most desktop PCs use 64-bit processors;
> I'd guess most phones and other consumer kit does as well.
>
> They will already have 64-bit registers, 64-bit stack slots, 64-bit
> addresses and will be using 64-bit floats.
>
> There's little advantage in having standalone int variables, parameters
> and return types being 32 bits. (For parameters, each will use a 64-bit
> register or stack slot anyway, and the return value will be in a 64-bit
> register.) Pointers of course will already be 64 bits.
>
> Sure, for arrays and structs, then you can choose narrower types if you
> want, since they can otherwise use twice as much memory, but not as a
> default type.
>
It's not the memory take, at least on a modern big system. It's the cache
usage. The processor spends a significant amount of its time refilling
the cache when it misses.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svqnh4$co8$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!Puiiztk9lHEEQC0y3uUjRA.user.46.165.242.75.POSTED!not-for-mail
From: non...@add.invalid (Manfred)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 16:40:21 +0100
Organization: Aioe.org NNTP Server
Message-ID: <svqnh4$co8$1@gioia.aioe.org>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="13064"; posting-host="Puiiztk9lHEEQC0y3uUjRA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-US
 by: Manfred - Thu, 3 Mar 2022 15:40 UTC

On 3/3/2022 4:19 PM, Malcolm McLean wrote:
> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>> On 3/2/2022 8:19 PM, Bart wrote:
>>
>> Are you seriously suggesting that the default size of int should be 64
>> bits everywhere?
>> Even for a general purpose counter from 1 to 10?
>>
> The vast majority of integers are small.

Yes, and there's an advantage in keeping their size somewhat limited,
even on 64 bit processors. I'd say that should be clear for anyone.

But there's a lot to be said for
> having one integer type which is used everywhere there isn't a strong
> case against, which can count any collection of objects in the computer's
> memory, and which is called "int".

Of course there can be a lot to be said, the definition of "int" is
(intentionally) left largely unspecified, and in every project lack of
specification leads to lots of discussion.

My point is that the issue should be looked at the other way around:

/If/ you have strong requirements on a variable, you choose its size
accordingly, and C gives you all the means to do that - expecially since
<stdint.h>

/If/ all you need is a general purpose integer, and you know its range
is limited, then you may delegate the final choice to the
implementation, which knows better how to optimize its performance -
that's what "int" is for.

In other words, if you have a sequence of readings from a sensor of
arbitrary length, and you index them with an "int", it's you who are
Doing it Wrong™.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<8735jzf3cj.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 03 Mar 2022 15:44:12 +0000
Organization: A noiseless patient Spider
Lines: 68
Message-ID: <8735jzf3cj.fsf@bsb.me.uk>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<87czj4jlwv.fsf@bsb.me.uk> <svoest$ase$1@dont-email.me>
<svokpo$tm8$1@dont-email.me> <87pmn4huz0.fsf@bsb.me.uk>
<svou8p$7qd$1@dont-email.me> <877d9bhpb0.fsf@bsb.me.uk>
<46685cb7-b2cd-4a50-80b2-94b4d79d0a50n@googlegroups.com>
<87pmn3g5jr.fsf@bsb.me.uk>
<cb5b8e98-5ff9-41eb-a1a8-41254789f996n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4aa79f9a4708fd38aa26eaecc64b4ca3";
logging-data="7098"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9VhQWwUaz3088aEPIsLYAbIbVhGWWoAA="
Cancel-Lock: sha1:3ZZ/+ae3/877VLXjnNhTSoAUTz8=
sha1:DckF6HGNAuj0dkRpxncoQjGUWaw=
X-BSB-Auth: 1.848da66ae60b87e7c9f3.20220303154412GMT.8735jzf3cj.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 3 Mar 2022 15:44 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:

> On Thursday, 3 March 2022 at 01:59:40 UTC, Ben Bacarisse wrote:

>> Also, I think you have slightly over complicated it. I'd write:
>>
>> void reduce_using(void *array, size_t esize, size_t nelem, void *dest,
>> void (*op)(void *dest, const void *a, const void *b))
>> {
>> memmove(dest, array, esize);
>> char (*elems)[esize] = array;
>> for (size_t i = 1; i < nelem; i++)
>> op(dest, dest, elems[i]);
>> }
>>
>> All the differences were deliberate, though some are just a matter of
>> preference. I've:
>>
>> * made the order and types of the size and count arguments the same as
>> for fread;
>>
> I was using qsort as the pattern.

(Except for the types!) I had not noticed they went the other way in
qsort. How annoying that there is no uniform convention.

I agree, though, that echoing qsort is better here since it is more
directly comparable.

>> * removed the context pointer as this should really only be used for
>> pure functions;
>>
> It probably will be null most of the time here, but it means that globals
> are never necessary.

I was making a stronger point: I would want to discourage use of this
function with anything but a pure operator. You can't enforce that, but
not provided in a context pointer is a big nudge.

>> * simplified the address calculation using a variably modified type (not
>> a VLA);
>>
> Oh, that's nice. But agian, it's confusing syntax. OTOH a cast to
> unsigned char * is also confusing.

It's confusing because it's not common, and that's a self-reinforcing
loop.

>> > C's not really designed to do this so it's a bit clumsy. But it
>> > doesn't require knowing that
>> > auto [a b] = x
>> > puts the first element of x in a, and the rest of the list in b. I't's
>> > all explicit.
>>
>> No, but it requires knowing lots of other things. I don't like these
>> "feature X is mysterious" augments as they just depend on what you
>> already know.
>>
> Most people who program C know an imperative programming language.
> But their eyes glaze over when presented with lots of ad-hoc syntax
> which deals mainly with the internals of the programming language itself
> rather than the data and algorithms the program is expressing.

Are you putting pattern matching (sometimes called destructuring) into
that category? I wouldn't.

--
Ben.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svqp1u$tmm$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 16:06:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <svqp1u$tmm$2@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 3 Mar 2022 16:06:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="bd150b0ee76e7ab3867294085372d456";
logging-data="30422"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX185umK0Q4cOGMH4awLPE3QeevCwcCfoIlw="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:BCzJS16KMxavnX158OQD6xA05s0=
 by: Lew Pitcher - Thu, 3 Mar 2022 16:06 UTC

On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:

> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>> On 3/2/2022 8:19 PM, Bart wrote:
>>
>> Are you seriously suggesting that the default size of int should be 64
>> bits everywhere?
>> Even for a general purpose counter from 1 to 10?
>>
> The vast majority of integers are small. But there's a lot to be said for
> having one integer type which is used everywhere there isn't a strong
> case against, which can count any collection of objects in the computer's
> memory, and which is called "int".

I think that your requirements are already met, with the exception that
the integer type is called
size_t
instead of
int

--
Lew Pitcher
"In Skills, We Trust"

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svqpi3$7ja$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 17:14:59 +0100
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <svqpi3$7ja$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
<svqp1u$tmm$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 16:14:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="498b7a2828220d39959d75bae7cf64b6";
logging-data="7786"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cBcNGIlGOYpUCHM+q3B/GLDu1v8x6dMk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:3odnaSeJwnXQHUGjikgyWn+5OK8=
In-Reply-To: <svqp1u$tmm$2@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Thu, 3 Mar 2022 16:14 UTC

Am 03.03.2022 um 17:06 schrieb Lew Pitcher:
> On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
>
>> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>
>>> Are you seriously suggesting that the default size of int should be 64
>>> bits everywhere?
>>> Even for a general purpose counter from 1 to 10?
>>>
>> The vast majority of integers are small. But there's a lot to be said for
>> having one integer type which is used everywhere there isn't a strong
>> case against, which can count any collection of objects in the computer's
>> memory, and which is called "int".
>
> I think that your requirements are already met, with the exception that
> the integer type is called
> size_t
> instead of
> int

ptrdiff_t is the int-counterpart that fits in a general purpose
register. size_t is unsigned.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svqqr1$j86$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 16:36:49 +0000
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <svqqr1$j86$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org> <svqkg5$q1i$1@dont-email.me>
<af49fea8-d5bf-43f1-88df-09393bf1835cn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 16:36:49 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cdd9ae9ac835544bf069b74349a5db5b";
logging-data="19718"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7MwC1gwKT/z65keU16yYR8MSkrQG8mKI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:U6a/hSPDMX6LWaBELtwi3R2cdJU=
In-Reply-To: <af49fea8-d5bf-43f1-88df-09393bf1835cn@googlegroups.com>
 by: Bart - Thu, 3 Mar 2022 16:36 UTC

On 03/03/2022 15:32, Malcolm McLean wrote:
> On Thursday, 3 March 2022 at 14:49:14 UTC, Bart wrote:
>> On 03/03/2022 14:09, Manfred wrote:
>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>> On 02/03/2022 18:06, rthiebaud wrote:
>>>>>>>>>> standard.
>>>>>>>>>>
>>>>>> * Whole-program compilers
>>>>>> * 64-bit everything (C is still stuck on 32-bits)
>>>>>> * Super-fast compilers ...
>>>>> Who says
>>>>> C is stuck is 32 bits?
>>>>
>>>> It just is. While versions with 64-bit ints might be knocking about,
>>>> generally they have to be compatible with what C already does on a
>>>> given platform. And that usually means int = 32 bits.
>>>>
>>>> So, while people can choose to use long long int or int64_t, they have
>>>> to explicity state that everywhere, because:
>>>>
>>>> 12345 is int32
>>>> 'A' is int32
>>>> short a,b,c;
>>>> a*b*c is int32 (so could overflow)
>>>> %d means int32 format
>>>> sprintf returns int32
>>>> f(){} defaults to int32 return type
>>>> int64_t a,b;
>>>> a && b is int32
>>>> !a is int32
>>>> enum E {a=5000000000};
>>>> enum E xx; is int32 (int64 on some compilers with extensions)
>>>>
>>>> etc
>>>
>> Are you seriously suggesting that the default size of int should be 64
>>> bits everywhere?
>>> Even for a general purpose counter from 1 to 10?
>> As BM said, even int32 is overkill in that case.
>>
>> But what exactly is the problem? Most desktop PCs use 64-bit processors;
>> I'd guess most phones and other consumer kit does as well.
>>
>> They will already have 64-bit registers, 64-bit stack slots, 64-bit
>> addresses and will be using 64-bit floats.
>>
>> There's little advantage in having standalone int variables, parameters
>> and return types being 32 bits. (For parameters, each will use a 64-bit
>> register or stack slot anyway, and the return value will be in a 64-bit
>> register.) Pointers of course will already be 64 bits.
>>
>> Sure, for arrays and structs, then you can choose narrower types if you
>> want, since they can otherwise use twice as much memory, but not as a
>> default type.
>>
> It's not the memory take, at least on a modern big system. It's the cache
> usage. The processor spends a significant amount of its time refilling
> the cache when it misses.

As I said elsewhere, where there is extensive memory usage such as in
arrays and arrays of structs, then you choose those elements accordingly.

But you will be already doing that when choosing 8-bit and 16-bit ints
over plain int, if int32 is not needed.

With local variables, generally they will be concentrated within a stack
region a few KB in size. Many will reside in registers anyway.

What might take extra time with 64 bits are ops like * and /; then you
might specifically choose an int32 type.

With an int64 type, you wouldn't really need separate types like size_t
(unless you want it as unsigned because you machine can actually address
2**64 bytes), off_t, intptr_t and so on. It can all become a lot tidier.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svqr9q$n98$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 16:44:42 +0000
Organization: A noiseless patient Spider
Lines: 32
Message-ID: <svqr9q$n98$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
<svqp1u$tmm$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 16:44:43 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cdd9ae9ac835544bf069b74349a5db5b";
logging-data="23848"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ajmq/2QVW3DdttzE2sVhc+5Ut5dsDLT0="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:h8DTtaJbJAc9dpf/ht8Qyp/UAD0=
In-Reply-To: <svqp1u$tmm$2@dont-email.me>
 by: Bart - Thu, 3 Mar 2022 16:44 UTC

On 03/03/2022 16:06, Lew Pitcher wrote:
> On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
>
>> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>
>>> Are you seriously suggesting that the default size of int should be 64
>>> bits everywhere?
>>> Even for a general purpose counter from 1 to 10?
>>>
>> The vast majority of integers are small. But there's a lot to be said for
>> having one integer type which is used everywhere there isn't a strong
>> case against, which can count any collection of objects in the computer's
>> memory, and which is called "int".
>
> I think that your requirements are already met, with the exception that
> the integer type is called
> size_t
> instead of
> int

This about the default int type, not user code choosing to use size_t.

Using size_t or uint64_t or int64_t or long long int for some explicit
types won't affect everything that defaults to 'int', or that has an int
result like !A.

Neither can it affect APIs of external libraries that use 'int'. Even if
you somehow, through macros or typedefs, manage to map 'int' to
'int64_t', when processing headers for those APIs, now the compiler will
incorrectly think they are using int64 types when they are actually int32.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<0N6UJ.234040$Rza5.5337@fx47.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx47.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Newsgroups: comp.lang.c
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com> <svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me> <svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me> <svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me> <svqi6n$1ccc$1@gioia.aioe.org> <2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com> <svqp1u$tmm$2@dont-email.me> <svqpi3$7ja$1@dont-email.me>
Lines: 27
Message-ID: <0N6UJ.234040$Rza5.5337@fx47.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 03 Mar 2022 17:19:56 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 03 Mar 2022 17:19:56 GMT
X-Received-Bytes: 2027
 by: Scott Lurndal - Thu, 3 Mar 2022 17:19 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 03.03.2022 um 17:06 schrieb Lew Pitcher:
>> On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
>>
>>> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>>
>>>> Are you seriously suggesting that the default size of int should be 64
>>>> bits everywhere?
>>>> Even for a general purpose counter from 1 to 10?
>>>>
>>> The vast majority of integers are small. But there's a lot to be said for
>>> having one integer type which is used everywhere there isn't a strong
>>> case against, which can count any collection of objects in the computer's
>>> memory, and which is called "int".
>>
>> I think that your requirements are already met, with the exception that
>> the integer type is called
>> size_t
>> instead of
>> int
>
>ptrdiff_t is the int-counterpart that fits in a general purpose
>register. size_t is unsigned.

Of course, one can alway use ssize_t.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svr4om$anv$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 20:26:13 +0100
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <svr4om$anv$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<87czj4jlwv.fsf@bsb.me.uk> <svoest$ase$1@dont-email.me>
<svokpo$tm8$1@dont-email.me> <87pmn4huz0.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 3 Mar 2022 19:26:14 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0b78661c57be5c4f4be73b9765ec66aa";
logging-data="11007"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LmJErMvjqcM4MM0KloDU+0AuauxAfu/o="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:FU1/4kaHJMRbYwwVuL9MZMrDU54=
In-Reply-To: <87pmn4huz0.fsf@bsb.me.uk>
Content-Language: en-GB
 by: David Brown - Thu, 3 Mar 2022 19:26 UTC

On 02/03/2022 23:04, Ben Bacarisse wrote:
> David Brown <david.brown@hesbynett.no> writes:
>
>> On 02/03/2022 20:00, Bart wrote:
>>> On 02/03/2022 17:37, Ben Bacarisse wrote:
>>>> Bart <bc@freeuk.com> writes:
>>>>
>>>>> On 02/03/2022 04:46, Bonita Montero wrote:
>>>>
>>>>>> OOP, RAII, generic programming, functional programming,
>>>>>> proper error-handling like with exceptions.
>>>>>
>>>>> They all sound like things designed to make coding harder and less
>>>>> accessible.
>>>>
>>>> OK, I'll bite.  Why would you not want type-generic functions?  You have
>>>> an array and you want the maximum.  Why write max (and probably the
>>>> array scanning) again and again just because sometimes it's an array of
>>>> int and sometimes an array of struct date?
>>>
>>>
>>> It's an idea that sounds good on paper, but look at how C++ does it for
>>> example, where I believe they are implemented via templates. Need I say
>>> more? But then C++ always seems to make a dog's dinner out of any feature.
>>
>> auto list_max(const auto& xs)
>> {
>> auto m = xs[0];
>> for (auto x : xs) {
>> m = (m > x) ? m : x;
>> }
>> return m;
>> }
>>
>> Yes, that's clearly a dog's dinner.
>
> Not everyone will be 100% happy with it. What if the xs are huge
> objects -- are they being copied and will that all that be optimised
> away? (I think I know the answers -- those are rhetorical questions.)
>
>>>> And then, since lots of operations are just array reductions based on
>>>> some binary operation, why write that again and again?  Functional
>>>> languages let you express the pattern once and for all so that
>>>>
>>>>   list_max(l)     = reduce_using(max, l)
>>>>   list_min(l)     = reduce_using(min, l)
>>>>   list_sum(l)     = reduce_using(+,   l)
>>>>   list_product(l) = reduce_using(*,   l)
>>>
>>
>> For your convenience, this is it in C++ (again, there are standard
>> library functions that could be used) :
>>
>> auto reduce_using(auto f, auto & xs) {
>> auto m = xs[0];
>> for (auto x : xs) {
>> m = f(m, x);
>> }
>> return m;
>> }
>
> But that's not my reduce_using.
>
>> auto list_max(const auto & xs) {
>> return reduce_using(
>> [](auto a, auto b) { return (a > b) ? a : b; },
>> xs);
>> }
>
> try the sum example with [](auto a, auto b) { return a + b; } and you'll
> see.

Yes. I also had this version :

auto reduce_using(auto f, const auto & xs) {
auto m = xs[0];
for (auto x : xs | std::views::drop(1)) {
m = f(m, x);
}
return m;
}

but I thought I'd keep it a little simpler for the demonstration. (It
also doesn't handle empty containers as it stands.)

>
>> A slightly nicer (IMHO) functional programming style would have :
>>
>> list_max = reduce_using(max)
>
> Of course. Indeed I wrote that (except without the ()s as it would be
> in Haskell) but then thought I don't want people being puzzled by the
> style.
>

Re: Linus Torvalds prepares to move the Linux kernel to modern C

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 03 Mar 2022 11:32:23 -0800
Organization: None to speak of
Lines: 38
Message-ID: <87ilsun86w.fsf@nosuchdomain.example.com>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
<svqp1u$tmm$2@dont-email.me> <svqpi3$7ja$1@dont-email.me>
<0N6UJ.234040$Rza5.5337@fx47.iad>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="bc127c93c7e625a029fcbff5935e8ad4";
logging-data="5488"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19e7305a8DxEQs3TrK3587G"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:W1nXPXMAQqBhA4GywqPXNNXe9r0=
sha1:9ORKBBn56jCIbdmWkQYFMd9OlmI=
 by: Keith Thompson - Thu, 3 Mar 2022 19:32 UTC

scott@slp53.sl.home (Scott Lurndal) writes:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>Am 03.03.2022 um 17:06 schrieb Lew Pitcher:
>>> On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
>>>
>>>> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>>>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>>>
>>>>> Are you seriously suggesting that the default size of int should be 64
>>>>> bits everywhere?
>>>>> Even for a general purpose counter from 1 to 10?
>>>>>
>>>> The vast majority of integers are small. But there's a lot to be said for
>>>> having one integer type which is used everywhere there isn't a strong
>>>> case against, which can count any collection of objects in the computer's
>>>> memory, and which is called "int".
>>>
>>> I think that your requirements are already met, with the exception that
>>> the integer type is called
>>> size_t
>>> instead of
>>> int
>>
>>ptrdiff_t is the int-counterpart that fits in a general purpose
>>register. size_t is unsigned.
>
> Of course, one can alway use ssize_t.

No, one can't always use ssize_t. It's defined by POSIX, not by ISO C
(even in the latest C23 draft), and POSIX doesn't guarantee that it's
the signed type corresponding to size_t.

ptrdiff_t is often the same size as size_t, but that's not guaranteed.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svr5v1$k99$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 20:46:40 +0100
Organization: A noiseless patient Spider
Lines: 107
Message-ID: <svr5v1$k99$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<87czj4jlwv.fsf@bsb.me.uk> <svoest$ase$1@dont-email.me>
<svokpo$tm8$1@dont-email.me> <87pmn4huz0.fsf@bsb.me.uk>
<svou8p$7qd$1@dont-email.me> <877d9bhpb0.fsf@bsb.me.uk>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 19:46:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0b78661c57be5c4f4be73b9765ec66aa";
logging-data="20777"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+1QXEYzhtmGFr0BZ27sWG0F9rz/T9poTg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:aMPAJNgx2RVKwkOW3Hx5aIP/QnY=
In-Reply-To: <877d9bhpb0.fsf@bsb.me.uk>
Content-Language: en-GB
 by: David Brown - Thu, 3 Mar 2022 19:46 UTC

On 03/03/2022 01:06, Ben Bacarisse wrote:
> Bart <bc@freeuk.com> writes:
>
>> On 02/03/2022 22:04, Ben Bacarisse wrote:
>>> David Brown <david.brown@hesbynett.no> writes:
>>>
>>>> On 02/03/2022 20:00, Bart wrote:
>>
>>>>> It's an idea that sounds good on paper, but look at how C++ does it for
>>>>> example, where I believe they are implemented via templates. Need I say
>>>>> more? But then C++ always seems to make a dog's dinner out of any feature.
>>>>
>>>> auto list_max(const auto& xs)
>>>> {
>>>> auto m = xs[0];
>>>> for (auto x : xs) {
>>>> m = (m > x) ? m : x;
>>>> }
>>>> return m;
>>>> }
>>>>
>>>> Yes, that's clearly a dog's dinner.
>>
>>> Not everyone will be 100% happy with it. What if the xs are huge
>>> objects -- are they being copied and will that all that be optimised
>>> away? (I think I know the answers -- those are rhetorical questions.)
>>
>> xs is passed by reference; why should there be copying? The result
>> will be one of the elements.
>>
>> If you mean the elements themselves might be large (eg. strings), then
>> it's something that the caller ought to aware of and do something
>> about.
>
> Finding and returning the maximum element in a collection only
> /requires/ one element be copied -- the one being returned. This code
> copies lots of elements about.
>
>> But it is easy to tweak, eg. return an index to the largest element
>> instead.
>
> By the code does not assume that there is an index. The tweak is to use
> references (or pointers) in the code and only copy one object on return.
>
>>>> auto reduce_using(auto f, auto & xs) {
>>>> auto m = xs[0];
>>>> for (auto x : xs) {
>>>> m = f(m, x);
>>>> }
>>>> return m;
>>>> }
>>>
>>> But that's not my reduce_using.
>>
>> You mean because it first applies f between xs[0] and xs[0] instead of
>> x[0] and x[1]? (Also the behaviour for an empty xs is not
>> clear). That's likely just an oversight.
>
> Yes, I know it's an oversight and in some way it's unfair to point it
> out since David is coding this "on the fly", but it sort of matters
> because it means you can't write it as simple as he is implying.
>
>> The examples were clearly mainly for my benefit in showing that C++ is
>> not that bad after all.
>
> Yes, and they do that. I was nit-picking.

The nit-picks are all valid. And that is a reason why it is often
better to use the standard library routines instead, such as
implementing reduce_using as something like :

constexpr auto reduce_using(auto f, auto &xs) {
auto i = std::begin(xs);
auto init = *i++;
return std::accumulate(i, std::end(xs), init);
}

(There isn't really anything it could reasonably return for an empty
container.)

But as you say, the main point was to show that templated code isn't
necessarily more difficult to write or understand than "normal" code.
(Sometimes templates can be complex, however - sometimes of necessity,
sometimes unnecessarily. I'll leave it to Bonita to provide examples :-) )

>
> By the way, among the things that all modern language designs should
> consider are type deduction (C++'s auto) and pattern matching. The
> latter could handle both omitting the extra call and signalling when the
> iterable is too short:
>
> auto reduce_using(auto f, auto &xs) {
> auto [m, rest] = xs; // raises an exception if xs.size() < 1
> for (auto &x : rest)
> m = f(m, x);
> return m;
> }
>
> There is a proposal for pattern matching in C++ (using a new keyword
> "inspect"), but I don't think it handles iterables.
>

I believe there have been many proposals for adding pattern matching to
C++ (and I hope we get one eventually). But I don't remember seeing any
that have the lovely "head ++ tail" pattern matching so standard in
functional programming.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<35111eff-6ba0-40fa-afe4-617349eb145bn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:6214:f2f:b0:432:c4c9:9953 with SMTP id iw15-20020a0562140f2f00b00432c4c99953mr21229216qvb.113.1646337488600;
Thu, 03 Mar 2022 11:58:08 -0800 (PST)
X-Received: by 2002:a37:5484:0:b0:477:78a7:a132 with SMTP id
i126-20020a375484000000b0047778a7a132mr568187qkb.94.1646337488440; Thu, 03
Mar 2022 11:58:08 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!border1.nntp.dca1.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: Thu, 3 Mar 2022 11:58:08 -0800 (PST)
In-Reply-To: <svr5v1$k99$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:5940:70d4:7b02:43a0;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:5940:70d4:7b02:43a0
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me> <svmsrh$6j9$1@dont-email.me>
<svnsgk$b0g$1@dont-email.me> <87czj4jlwv.fsf@bsb.me.uk> <svoest$ase$1@dont-email.me>
<svokpo$tm8$1@dont-email.me> <87pmn4huz0.fsf@bsb.me.uk> <svou8p$7qd$1@dont-email.me>
<877d9bhpb0.fsf@bsb.me.uk> <svr5v1$k99$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <35111eff-6ba0-40fa-afe4-617349eb145bn@googlegroups.com>
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 03 Mar 2022 19:58:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 84
 by: Malcolm McLean - Thu, 3 Mar 2022 19:58 UTC

On Thursday, 3 March 2022 at 19:47:11 UTC, David Brown wrote:
> On 03/03/2022 01:06, Ben Bacarisse wrote:
> > Bart <b...@freeuk.com> writes:
> >
> >> On 02/03/2022 22:04, Ben Bacarisse wrote:
> >>> David Brown <david...@hesbynett.no> writes:
> >>>
> >>>> On 02/03/2022 20:00, Bart wrote:
> >>
> >>>>> It's an idea that sounds good on paper, but look at how C++ does it for
> >>>>> example, where I believe they are implemented via templates. Need I say
> >>>>> more? But then C++ always seems to make a dog's dinner out of any feature.
> >>>>
> >>>> auto list_max(const auto& xs)
> >>>> {
> >>>> auto m = xs[0];
> >>>> for (auto x : xs) {
> >>>> m = (m > x) ? m : x;
> >>>> }
> >>>> return m;
> >>>> }
> >>>>
> >>>> Yes, that's clearly a dog's dinner.
> >>
> >>> Not everyone will be 100% happy with it. What if the xs are huge
> >>> objects -- are they being copied and will that all that be optimised
> >>> away? (I think I know the answers -- those are rhetorical questions.)
> >>
> >> xs is passed by reference; why should there be copying? The result
> >> will be one of the elements.
> >>
> >> If you mean the elements themselves might be large (eg. strings), then
> >> it's something that the caller ought to aware of and do something
> >> about.
> >
> > Finding and returning the maximum element in a collection only
> > /requires/ one element be copied -- the one being returned. This code
> > copies lots of elements about.
> >
> >> But it is easy to tweak, eg. return an index to the largest element
> >> instead.
> >
> > By the code does not assume that there is an index. The tweak is to use
> > references (or pointers) in the code and only copy one object on return.
> >
> >>>> auto reduce_using(auto f, auto & xs) {
> >>>> auto m = xs[0];
> >>>> for (auto x : xs) {
> >>>> m = f(m, x);
> >>>> }
> >>>> return m;
> >>>> }
> >>>
> >>> But that's not my reduce_using.
> >>
> >> You mean because it first applies f between xs[0] and xs[0] instead of
> >> x[0] and x[1]? (Also the behaviour for an empty xs is not
> >> clear). That's likely just an oversight.
> >
> > Yes, I know it's an oversight and in some way it's unfair to point it
> > out since David is coding this "on the fly", but it sort of matters
> > because it means you can't write it as simple as he is implying.
> >
> >> The examples were clearly mainly for my benefit in showing that C++ is
> >> not that bad after all.
> >
> > Yes, and they do that. I was nit-picking.
> The nit-picks are all valid. And that is a reason why it is often
> better to use the standard library routines instead, such as
> implementing reduce_using as something like :
>
> constexpr auto reduce_using(auto f, auto &xs) {
> auto i = std::begin(xs);
> auto init = *i++;
> return std::accumulate(i, std::end(xs), init);
> }
>
I don't see the call to f() anywhere in this code. Presumably
an error. Also, "auto" helps the compiler out, but it's not terribly
useful to the maintaining programmer. f has to be a callable
function that takes two objects of the type contained in xs
and returns an object of the same same. xs has to be a container
with an stl-like iterator system defined, and needs to be filled with
at least one object of the type returned by f.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svr7ql$3dh$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 21:18:29 +0100
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <svr7ql$3dh$2@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<87czj4jlwv.fsf@bsb.me.uk> <svoest$ase$1@dont-email.me>
<svokpo$tm8$1@dont-email.me> <87pmn4huz0.fsf@bsb.me.uk>
<svou8p$7qd$1@dont-email.me> <877d9bhpb0.fsf@bsb.me.uk>
<svr5v1$k99$1@dont-email.me>
<35111eff-6ba0-40fa-afe4-617349eb145bn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 20:18:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="0b78661c57be5c4f4be73b9765ec66aa";
logging-data="3505"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vHyCgA1Y2jXCfN6hPafXw2PiidzY4MpM="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:oGc4er/wIkKhMbsoQcNZ5sUB93Q=
In-Reply-To: <35111eff-6ba0-40fa-afe4-617349eb145bn@googlegroups.com>
Content-Language: en-GB
 by: David Brown - Thu, 3 Mar 2022 20:18 UTC

On 03/03/2022 20:58, Malcolm McLean wrote:
> On Thursday, 3 March 2022 at 19:47:11 UTC, David Brown wrote:
>> On 03/03/2022 01:06, Ben Bacarisse wrote:
>>> Bart <b...@freeuk.com> writes:
>>>
>>>> On 02/03/2022 22:04, Ben Bacarisse wrote:
>>>>> David Brown <david...@hesbynett.no> writes:
>>>>>
>>>>>> On 02/03/2022 20:00, Bart wrote:
>>>>
>>>>>>> It's an idea that sounds good on paper, but look at how C++ does it for
>>>>>>> example, where I believe they are implemented via templates. Need I say
>>>>>>> more? But then C++ always seems to make a dog's dinner out of any feature.
>>>>>>
>>>>>> auto list_max(const auto& xs)
>>>>>> {
>>>>>> auto m = xs[0];
>>>>>> for (auto x : xs) {
>>>>>> m = (m > x) ? m : x;
>>>>>> }
>>>>>> return m;
>>>>>> }
>>>>>>
>>>>>> Yes, that's clearly a dog's dinner.
>>>>
>>>>> Not everyone will be 100% happy with it. What if the xs are huge
>>>>> objects -- are they being copied and will that all that be optimised
>>>>> away? (I think I know the answers -- those are rhetorical questions.)
>>>>
>>>> xs is passed by reference; why should there be copying? The result
>>>> will be one of the elements.
>>>>
>>>> If you mean the elements themselves might be large (eg. strings), then
>>>> it's something that the caller ought to aware of and do something
>>>> about.
>>>
>>> Finding and returning the maximum element in a collection only
>>> /requires/ one element be copied -- the one being returned. This code
>>> copies lots of elements about.
>>>
>>>> But it is easy to tweak, eg. return an index to the largest element
>>>> instead.
>>>
>>> By the code does not assume that there is an index. The tweak is to use
>>> references (or pointers) in the code and only copy one object on return.
>>>
>>>>>> auto reduce_using(auto f, auto & xs) {
>>>>>> auto m = xs[0];
>>>>>> for (auto x : xs) {
>>>>>> m = f(m, x);
>>>>>> }
>>>>>> return m;
>>>>>> }
>>>>>
>>>>> But that's not my reduce_using.
>>>>
>>>> You mean because it first applies f between xs[0] and xs[0] instead of
>>>> x[0] and x[1]? (Also the behaviour for an empty xs is not
>>>> clear). That's likely just an oversight.
>>>
>>> Yes, I know it's an oversight and in some way it's unfair to point it
>>> out since David is coding this "on the fly", but it sort of matters
>>> because it means you can't write it as simple as he is implying.
>>>
>>>> The examples were clearly mainly for my benefit in showing that C++ is
>>>> not that bad after all.
>>>
>>> Yes, and they do that. I was nit-picking.
>> The nit-picks are all valid. And that is a reason why it is often
>> better to use the standard library routines instead, such as
>> implementing reduce_using as something like :
>>
>> constexpr auto reduce_using(auto f, auto &xs) {
>> auto i = std::begin(xs);
>> auto init = *i++;
>> return std::accumulate(i, std::end(xs), init);
>> }
>>
> I don't see the call to f() anywhere in this code. Presumably
> an error.

Yes - the code was not tested at all (obviously).

return std::accumulate(i, std::end(xs), init, f);

> Also, "auto" helps the compiler out, but it's not terribly
> useful to the maintaining programmer. f has to be a callable
> function that takes two objects of the type contained in xs
> and returns an object of the same same. xs has to be a container
> with an stl-like iterator system defined, and needs to be filled with
> at least one object of the type returned by f.
>

Sure, "auto" can be replaced by a useful concept name.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 03 Mar 2022 20:19:17 +0000
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <87wnhaeqm2.fsf@bsb.me.uk>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<87czj4jlwv.fsf@bsb.me.uk> <svoest$ase$1@dont-email.me>
<svokpo$tm8$1@dont-email.me> <87pmn4huz0.fsf@bsb.me.uk>
<svr4om$anv$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4aa79f9a4708fd38aa26eaecc64b4ca3";
logging-data="5003"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Fk2yUSZIsF64kf7TZxlV7CgUaGeLHoMI="
Cancel-Lock: sha1:EDy0gqMQHAu9zTV97ZVkgFKiLQc=
sha1:k7ZH3nR0WnskLdeHhWoNmE9no98=
X-BSB-Auth: 1.0f05963be3558501f4a9.20220303201917GMT.87wnhaeqm2.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 3 Mar 2022 20:19 UTC

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

> Yes. I also had this version :
>
> auto reduce_using(auto f, const auto & xs) {
> auto m = xs[0];
> for (auto x : xs | std::views::drop(1)) {
> m = f(m, x);
> }
> return m;
> }
>
> but I thought I'd keep it a little simpler for the demonstration. (It
> also doesn't handle empty containers as it stands.)

And then you are almost writing Haskell -- composing closures with an
overloaded | operator!

You could have compromised and done the drop directly:

for (auto x : std::ranges::drop_view(xs, 1)) ...

but I suppose everyone will have to get used to the x | view1 | view2
pattern soon enough.

--
Ben.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svr87u$76l$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.programming.threads comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 12:25:33 -0800
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <svr87u$76l$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 20:25:34 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e45d6f23c2260ccf8b0ddf392789ad41";
logging-data="7381"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+TxZlPbDLS4Ur8BVIKWgeGH3uv08z88SY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:m40po5OrTtzMLGsHh27zJIs36FM=
In-Reply-To: <svj1m6$rue$2@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 3 Mar 2022 20:25 UTC

On 2/28/2022 9:44 AM, Bonita Montero wrote:
> Am 28.02.2022 um 17:43 schrieb Amine Moulay Ramdane:
>> Hello,
>>
>>
>> Linus Torvalds prepares to move the Linux kernel to modern C
>>
>> The Linux kernel's foundation is the ancient C89 standard of C. Now,
>> Torvalds has decided to upgrade to 2011's more modern C11 standard.
>>
>> Read more here:
>>
>> https://www.zdnet.com/article/linus-torvalds-prepares-to-move-the-linux-kernel-to-modern-c/?ftag=COS-05-10aaa0h&utm_campaign=trueAnthem%3A%20Trending%20Content&utm_medium=trueAnthem&utm_source=facebook&fbclid=IwAR1oF1ysACG28YRYJnnYlt7oCzfRhXSUePOKd4xsycb3F8GGwxIfeAXZI8Y
>>
>>
>>
>> Thank you,
>> Amine Moulay Ramdane.
>
> C isn't a modern language, no matter which standard.

Moving Linux to Standard C11 has to involve a lot of porting over to the
std atomics and membars in C11.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!news.freedyn.de!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 03 Mar 2022 20:31:25 +0000
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <87r17ieq1u.fsf@bsb.me.uk>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<87czj4jlwv.fsf@bsb.me.uk> <svoest$ase$1@dont-email.me>
<svokpo$tm8$1@dont-email.me> <87pmn4huz0.fsf@bsb.me.uk>
<svou8p$7qd$1@dont-email.me> <877d9bhpb0.fsf@bsb.me.uk>
<svr5v1$k99$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4aa79f9a4708fd38aa26eaecc64b4ca3";
logging-data="5003"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/rVTMpimPg7VPtskYrxPqnxjBBbNXeOxQ="
Cancel-Lock: sha1:PX67zaYFY+xhSNG/+aUDHoS8fkw=
sha1:0/Z72z14AKW+UyrKYPc4GJfVnEU=
X-BSB-Auth: 1.863114feccdaf65729ec.20220303203125GMT.87r17ieq1u.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 3 Mar 2022 20:31 UTC

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

> On 03/03/2022 01:06, Ben Bacarisse wrote:
>> Bart <bc@freeuk.com> writes:

>>> The examples were clearly mainly for my benefit in showing that C++ is
>>> not that bad after all.
>>
>> Yes, and they do that. I was nit-picking.
>
> The nit-picks are all valid. And that is a reason why it is often
> better to use the standard library routines instead, such as
> implementing reduce_using as something like :
>
> constexpr auto reduce_using(auto f, auto &xs) {
> auto i = std::begin(xs);
> auto init = *i++;
> return std::accumulate(i, std::end(xs), init);
> }

(The f is missing as the last argument.)

I suspect this, including a drop(1), can be done with std::views since
they can combine with std::algorithms (but I'm guessing).

> I believe there have been many proposals for adding pattern matching to
> C++ (and I hope we get one eventually). But I don't remember seeing any
> that have the lovely "head ++ tail" pattern matching so standard in
> functional programming.

Extreme topic drift now, but it's usually head : tail. I've only seen
++ as a list append operator, and matching against that would force head
to be a list as well as tail (with undefined consequences).

--
Ben.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svr8u1$d5m$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.programming.threads comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Bonita.M...@gmail.com (Bonita Montero)
Newsgroups: comp.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 21:37:20 +0100
Organization: A noiseless patient Spider
Lines: 26
Message-ID: <svr8u1$d5m$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svr87u$76l$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 20:37:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="498b7a2828220d39959d75bae7cf64b6";
logging-data="13494"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19snp29RDRoR3aBmRqDT81xjZxGP5xdUcM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:9ZfTxJQkO3QN477p5/Ox8AWR9ak=
In-Reply-To: <svr87u$76l$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Thu, 3 Mar 2022 20:37 UTC

Am 03.03.2022 um 21:25 schrieb Chris M. Thomasson:
> On 2/28/2022 9:44 AM, Bonita Montero wrote:
>> Am 28.02.2022 um 17:43 schrieb Amine Moulay Ramdane:
>>> Hello,
>>>
>>>
>>> Linus Torvalds prepares to move the Linux kernel to modern C
>>>
>>> The Linux kernel's foundation is the ancient C89 standard of C. Now,
>>> Torvalds has decided to upgrade to 2011's more modern C11 standard.
>>>
>>> Read more here:
>>>
>>> https://www.zdnet.com/article/linus-torvalds-prepares-to-move-the-linux-kernel-to-modern-c/?ftag=COS-05-10aaa0h&utm_campaign=trueAnthem%3A%20Trending%20Content&utm_medium=trueAnthem&utm_source=facebook&fbclid=IwAR1oF1ysACG28YRYJnnYlt7oCzfRhXSUePOKd4xsycb3F8GGwxIfeAXZI8Y
>>>
>>>
>>>
>>> Thank you,
>>> Amine Moulay Ramdane.
>>
>> C isn't a modern language, no matter which standard.
>
> Moving Linux to Standard C11 has to involve a lot of porting over to the
> std atomics and membars in C11.

The code needs not to be portable beyond gcc and clang.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svra78$no8$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.programming.threads comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: chris.m....@gmail.com (Chris M. Thomasson)
Newsgroups: comp.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 12:59:18 -0800
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <svra78$no8$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svr87u$76l$1@dont-email.me>
<svr8u1$d5m$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 20:59:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="e45d6f23c2260ccf8b0ddf392789ad41";
logging-data="24328"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/qPlxU4FNiJ8I7zq53fCsqoZ4fEkIGXTc="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:D3BUS/5gcL4d5lq4Q+2A/UrxuvM=
In-Reply-To: <svr8u1$d5m$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Thu, 3 Mar 2022 20:59 UTC

On 3/3/2022 12:37 PM, Bonita Montero wrote:
> Am 03.03.2022 um 21:25 schrieb Chris M. Thomasson:
>> On 2/28/2022 9:44 AM, Bonita Montero wrote:
>>> Am 28.02.2022 um 17:43 schrieb Amine Moulay Ramdane:
>>>> Hello,
>>>>
>>>>
>>>> Linus Torvalds prepares to move the Linux kernel to modern C
>>>>
>>>> The Linux kernel's foundation is the ancient C89 standard of C. Now,
>>>> Torvalds has decided to upgrade to 2011's more modern C11 standard.
>>>>
>>>> Read more here:
>>>>
>>>> https://www.zdnet.com/article/linus-torvalds-prepares-to-move-the-linux-kernel-to-modern-c/?ftag=COS-05-10aaa0h&utm_campaign=trueAnthem%3A%20Trending%20Content&utm_medium=trueAnthem&utm_source=facebook&fbclid=IwAR1oF1ysACG28YRYJnnYlt7oCzfRhXSUePOKd4xsycb3F8GGwxIfeAXZI8Y
>>>>
>>>>
>>>>
>>>> Thank you,
>>>> Amine Moulay Ramdane.
>>>
>>> C isn't a modern language, no matter which standard.
>>
>> Moving Linux to Standard C11 has to involve a lot of porting over to
>> the std atomics and membars in C11.
>
> The code needs not to be portable beyond gcc and clang.

Well, I was thinking if they altered their existing atomics and membars
to 100% pure C11, that would be a shit load of work. I can do it, but it
would take a very long time.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svrcb2$965$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: vir.camp...@invalid.invalid (Vir Campestris)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 21:35:29 +0000
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <svrcb2$965$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
<svqp1u$tmm$2@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 21:35:30 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8028669eddce9498671b52e22d96823e";
logging-data="9413"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EaycvMMicomEjYPZyKi5fdv4TbIFVEqk="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:gf50fZt3J+VgvJnWYtwkmfTGSno=
In-Reply-To: <svqp1u$tmm$2@dont-email.me>
Content-Language: en-GB
 by: Vir Campestris - Thu, 3 Mar 2022 21:35 UTC

On 03/03/2022 16:06, Lew Pitcher wrote:
> On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
>
>> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>
>>> Are you seriously suggesting that the default size of int should be 64
>>> bits everywhere?
>>> Even for a general purpose counter from 1 to 10?
>>>
>> The vast majority of integers are small. But there's a lot to be said for
>> having one integer type which is used everywhere there isn't a strong
>> case against, which can count any collection of objects in the computer's
>> memory, and which is called "int".
>
> I think that your requirements are already met, with the exception that
> the integer type is called
> size_t
> instead of
> int
>
size_t makes sense. It's a platform sized value which is the largest
possible array index.

But int? What does it mean if the collection size is -1?

unsigned might be right. On some platforms, but not all the ones I've
used in the past.

int has always been at least 16 bits for me. 32 usually these days, but
I have used systems where it's 64.

And in the dim distant past when I wasn't writing C an integer was 24 or
64 bits on 2 different mainframes.

There's also no guarantee that the size of a pointer is the same as the
size of the array index... some architectures embed checks in the pointers.

Andy

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svrclm$boj$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.programming.threads comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: vir.camp...@invalid.invalid (Vir Campestris)
Newsgroups: comp.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 21:41:10 +0000
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <svrclm$boj$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svjsnm$dnp$1@dont-email.me>
<svjsuj$eoc$1@dont-email.me> <svk03m$3ac$1@dont-email.me>
<svl77v$vmc$1@dont-email.me> <svlhdt$f5f$1@dont-email.me>
<svlk76$5tq$1@dont-email.me> <svlpfg$j88$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 3 Mar 2022 21:41:10 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="8028669eddce9498671b52e22d96823e";
logging-data="12051"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18EGiGzH2gi7ScJptHQF/M9kTBTpN/F3tg="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:9tgwm/5fphvVkgE5WfUCLQPxntc=
In-Reply-To: <svlpfg$j88$1@dont-email.me>
Content-Language: en-GB
 by: Vir Campestris - Thu, 3 Mar 2022 21:41 UTC

On 01/03/2022 18:42, David Brown wrote:
> That does not contradict me in any way. Companies are looking for new
> people with C++ skills, because - as I said - the use of C++ in embedded
> systems is/increasing/. They don't need new C programmers, because
> they already have C programmers.

We're embedded systems. (though it seems odd to me to use that term for
something with a thousand times more memory than the mainframes I
started on...)

The OS layer is Linux, and it's in C. Including the libraries we get
from the chip manufacturers, and we often end up hacking them. We don't
often have to fiddle with Linux, but it's not that rare we're looking
into the code to see what went wrong...

The application we run on top is entirely C++.

At the skill levels we require I would be astounded to find anyone who
cannot use both languages at least to some degree.

That's skill BTW, not experience - we have an intern system where we
bring in undergraduates for their last summer. A lot of them get job offers.

Andy

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<cde96635-397e-4ce0-a74f-4fd4300bec25n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:588d:0:b0:2de:892:48c6 with SMTP id t13-20020ac8588d000000b002de089248c6mr29211161qta.439.1646344071378;
Thu, 03 Mar 2022 13:47:51 -0800 (PST)
X-Received: by 2002:a05:620a:99a:b0:662:d09c:1b39 with SMTP id
x26-20020a05620a099a00b00662d09c1b39mr781430qkx.151.1646344071210; Thu, 03
Mar 2022 13:47:51 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 3 Mar 2022 13:47:50 -0800 (PST)
In-Reply-To: <svrcb2$965$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:5940:70d4:7b02:43a0;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:5940:70d4:7b02:43a0
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me> <svmsrh$6j9$1@dont-email.me>
<svnsgk$b0g$1@dont-email.me> <svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org> <2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
<svqp1u$tmm$2@dont-email.me> <svrcb2$965$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cde96635-397e-4ce0-a74f-4fd4300bec25n@googlegroups.com>
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 03 Mar 2022 21:47:51 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Malcolm McLean - Thu, 3 Mar 2022 21:47 UTC

On Thursday, 3 March 2022 at 21:36:09 UTC, Vir Campestris wrote:
> On 03/03/2022 16:06, Lew Pitcher wrote:
> > On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
> >
> >> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
> >>> On 3/2/2022 8:19 PM, Bart wrote:
> >>>
> >>> Are you seriously suggesting that the default size of int should be 64
> >>> bits everywhere?
> >>> Even for a general purpose counter from 1 to 10?
> >>>
> >> The vast majority of integers are small. But there's a lot to be said for
> >> having one integer type which is used everywhere there isn't a strong
> >> case against, which can count any collection of objects in the computer's
> >> memory, and which is called "int".
> >
> > I think that your requirements are already met, with the exception that
> > the integer type is called
> > size_t
> > instead of
> > int
> >
> size_t makes sense. It's a platform sized value which is the largest
> possible array index.
>
> But int? What does it mean if the collection size is -1?
>
void tail(double *x, size_t N)
{ size_t i;
for (i =0; i < N-1; i++)
x[i] = x[i+1];
}

void caller(void)
{ size_t N;
double * x = inputarrayfromuser(&N);
// throw away first value
tail(x, N);
}

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<svrd2b$ei1$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 21:47:55 +0000
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <svrd2b$ei1$1@dont-email.me>
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com>
<svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me>
<svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me>
<svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me>
<svqi6n$1ccc$1@gioia.aioe.org>
<2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com>
<svqp1u$tmm$2@dont-email.me> <svrcb2$965$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 3 Mar 2022 21:47:55 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cdd9ae9ac835544bf069b74349a5db5b";
logging-data="14913"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1995FbA/K/JQCWer0ELaGOyiamtUZoIn8w="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:XhDuS2zf5FUZSOi27FNmAZCPd/w=
In-Reply-To: <svrcb2$965$1@dont-email.me>
 by: Bart - Thu, 3 Mar 2022 21:47 UTC

On 03/03/2022 21:35, Vir Campestris wrote:
> On 03/03/2022 16:06, Lew Pitcher wrote:
>> On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
>>
>>> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>>
>>>> Are you seriously suggesting that the default size of int should be 64
>>>> bits everywhere?
>>>> Even for a general purpose counter from 1 to 10?
>>>>
>>> The vast majority of integers are small. But there's a lot to be said
>>> for
>>> having one integer type which is used everywhere there isn't a strong
>>> case against, which can count any collection of objects in the
>>> computer's
>>> memory, and which is called "int".
>>
>> I think that your requirements are already met, with the exception that
>> the integer type is called
>>    size_t
>> instead of
>>    int
>>
> size_t makes sense. It's a platform sized value which is the largest
> possible array index.
>
> But int? What does it mean if the collection size is -1?

What does it mean if the size is 2**64-1?

I have however used a length of -1 to indicate the length was unknown or
not set or not valid.

> unsigned might be right. On some platforms, but not all the ones I've
> used in the past.
>
> int has always been at least 16 bits for me. 32 usually these days, but
> I have used systems where it's 64.

It should be a 'don't care' width. But these days you need to care too
often whether a 32-bit width is sufficient. (Memory size calculations;
file/disk sizes; the number of people on the planet; type-punning
pointers or doubles. 64 bits is a no-brainer.)

> And in the dim distant past when I wasn't writing C an integer was 24 or
> 64 bits on 2 different mainframes.
>
> There's also no guarantee that the size of a pointer is the same as the
> size of the array index... some architectures embed checks in the pointers.

And a HLL can ensure that the programmer sees a model where they /are/
the same. That's why it's a HLL.

Re: Linus Torvalds prepares to move the Linux kernel to modern C

<4RaUJ.90313$aT3.79887@fx09.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!ecngs!feeder2.ecngs.de!178.20.174.213.MISMATCH!feeder1.feed.usenet.farm!feed.usenet.farm!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx09.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Newsgroups: comp.lang.c
References: <88f5394b-c1a1-4422-a20f-96e5511a178fn@googlegroups.com> <svj1m6$rue$2@dont-email.me> <svmspn$5e7$1@dont-email.me> <svmsrh$6j9$1@dont-email.me> <svnsgk$b0g$1@dont-email.me> <svobnq$d5p$1@dont-email.me> <svofvi$kbb$1@dont-email.me> <svqi6n$1ccc$1@gioia.aioe.org> <2f12cd83-7ac3-49c5-b993-a97933359214n@googlegroups.com> <svqp1u$tmm$2@dont-email.me> <svqpi3$7ja$1@dont-email.me> <0N6UJ.234040$Rza5.5337@fx47.iad> <87ilsun86w.fsf@nosuchdomain.example.com>
Lines: 37
Message-ID: <4RaUJ.90313$aT3.79887@fx09.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 03 Mar 2022 21:57:20 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 03 Mar 2022 21:57:20 GMT
X-Received-Bytes: 2520
 by: Scott Lurndal - Thu, 3 Mar 2022 21:57 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>scott@slp53.sl.home (Scott Lurndal) writes:
>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>>Am 03.03.2022 um 17:06 schrieb Lew Pitcher:
>>>> On Thu, 03 Mar 2022 07:19:55 -0800, Malcolm McLean wrote:
>>>>
>>>>> On Thursday, 3 March 2022 at 14:10:06 UTC, Manfred wrote:
>>>>>> On 3/2/2022 8:19 PM, Bart wrote:
>>>>>>
>>>>>> Are you seriously suggesting that the default size of int should be 64
>>>>>> bits everywhere?
>>>>>> Even for a general purpose counter from 1 to 10?
>>>>>>
>>>>> The vast majority of integers are small. But there's a lot to be said for
>>>>> having one integer type which is used everywhere there isn't a strong
>>>>> case against, which can count any collection of objects in the computer's
>>>>> memory, and which is called "int".
>>>>
>>>> I think that your requirements are already met, with the exception that
>>>> the integer type is called
>>>> size_t
>>>> instead of
>>>> int
>>>
>>>ptrdiff_t is the int-counterpart that fits in a general purpose
>>>register. size_t is unsigned.
>>
>> Of course, one can alway use ssize_t.
>
>No, one can't always use ssize_t. It's defined by POSIX, not by ISO C
>(even in the latest C23 draft), and POSIX doesn't guarantee that it's
>the signed type corresponding to size_t.

Yes, one can always use ssize_t.

typedef signed long int ssize_t;

Pages:1234
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor