Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Saint: A dead sinner revised and edited. -- Ambrose Bierce


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

<svobnq$d5p$1@dont-email.me>

  copy mid

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

  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: thiebaud...@aol.com (rthiebaud)
Newsgroups: comp.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Wed, 2 Mar 2022 13:06:50 -0500
Organization: A noiseless patient Spider
Lines: 7
Message-ID: <svobnq$d5p$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 18:06:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="b3e9f741b668ed228e45663f06d67f33";
logging-data="13497"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PNFynIKLpqMge011OoE7G4bRKoSOYJmU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:JVjKuHIWoSQlfGoFv9s5aLzOt+c=
In-Reply-To: <svnsgk$b0g$1@dont-email.me>
Content-Language: en-US
 by: rthiebaud - Wed, 2 Mar 2022 18:06 UTC

>>>>> 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?

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

<svoc90$is5$1@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 19:16:05 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <svoc90$is5$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>
<ffde6e78-6223-43e3-acb4-809c32e48487n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 18:16:00 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="19333"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1811Refkz6DYPbi6oYw3zAAtkMWtTlpSwA="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:3COdzqckuwqoQaKMAU9Lwllb8r0=
In-Reply-To: <ffde6e78-6223-43e3-acb4-809c32e48487n@googlegroups.com>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 18:16 UTC

Am 02.03.2022 um 12:17 schrieb Malcolm McLean:
> On Wednesday, 2 March 2022 at 04:47:07 UTC, Bonita Montero wrote:
>> Am 02.03.2022 um 05:45 schrieb Lynn McGuire:
>>> On 2/28/2022 11: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.
>>>
>>> What is your definition of a modern language ?
>> OOP, RAII, generic programming, functional programming,
>> proper error-handling like with exceptions.
>>
> That's fair enough. With the exception of functional programming, these have all been
> introduced since C was first developed.

There's no OOP, no RAII, no usable generic proigramming
and no proper error-handling.

> You can argue about the benefits. Especially in C++, where these ideas have to be
> bolted onto an existing language rather than implemented in a consistent way in
> the basic design.

C++ isn't easy to handle for someone working with it just for
some weeks, but it is magnitudes more powerful.

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

<svocba$is5$2@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 19:17:20 +0100
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <svocba$is5$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 18:17:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="19333"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19aJpZk83QMHPl6r0RT9l6RF51N6HLC8RM="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:5ORZ9OhsMuVBfe94VXY0DruAhms=
In-Reply-To: <svnsgk$b0g$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 18:17 UTC

Am 02.03.2022 um 14:47 schrieb Bart:
> On 02/03/2022 04:46, Bonita Montero wrote:
>> Am 02.03.2022 um 05:45 schrieb Lynn McGuire:
>>> On 2/28/2022 11: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.
>>>
>>> What is your definition of a modern language ?
>>
>> 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.

No, it's the opposite. They make code much more readable
and you're a magnitude more productive.

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

<svocct$is5$3@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 19:18:11 +0100
Organization: A noiseless patient Spider
Lines: 45
Message-ID: <svocct$is5$3@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> <bnLTJ.29022$aT3.9637@fx09.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 18:18:05 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="19333"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+MmmySzzyVC6sQitlJ3buZm63ExJ09eQU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:sfFakosWN0W0+PyjbbFggBTI6c0=
In-Reply-To: <bnLTJ.29022$aT3.9637@fx09.iad>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 18:18 UTC

Am 02.03.2022 um 15:42 schrieb Scott Lurndal:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> Am 02.03.2022 um 05:45 schrieb Lynn McGuire:
>>> On 2/28/2022 11: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.
>>>
>>> What is your definition of a modern language ?
>>
>> OOP,
>
> Simula, 1967.
>
>
>> RAII,
>
> ADA, 1980.
>
>> generic programming,
>
> ML, 1973.
>
>> functional programming,
>
> Lisp, 1970's.

We're talking about C++ vs. C.

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

<kMOTJ.47117$m1S7.30500@fx36.iad>

  copy mid

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

  copy link   Newsgroups: comp.programming.threads comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.mixmin.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.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.programming.threads,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> <bnLTJ.29022$aT3.9637@fx09.iad> <svocct$is5$3@dont-email.me>
Lines: 49
Message-ID: <kMOTJ.47117$m1S7.30500@fx36.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Wed, 02 Mar 2022 18:33:52 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Wed, 02 Mar 2022 18:33:52 GMT
X-Received-Bytes: 2264
 by: Scott Lurndal - Wed, 2 Mar 2022 18:33 UTC

Bonita Montero <Bonita.Montero@gmail.com> writes:
>Am 02.03.2022 um 15:42 schrieb Scott Lurndal:
>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>> Am 02.03.2022 um 05:45 schrieb Lynn McGuire:
>>>> On 2/28/2022 11: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.
>>>>
>>>> What is your definition of a modern language ?
>>>
>>> OOP,
>>
>> Simula, 1967.
>>
>>
>>> RAII,
>>
>> ADA, 1980.
>>
>>> generic programming,
>>
>> ML, 1973.
>>
>>> functional programming,
>>
>> Lisp, 1970's.

> We're talking about C++ vs. C.

Lesen sie besser.

"What is your definition of a modern language"

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

<svodkd$t2l$1@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 19:39:14 +0100
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <svodkd$t2l$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> <bnLTJ.29022$aT3.9637@fx09.iad>
<svocct$is5$3@dont-email.me> <kMOTJ.47117$m1S7.30500@fx36.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 18:39:09 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="29781"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+txEsOAZP+xoYRA3mH8N7UDOfWfcVWp88="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:ox/1q9U+6g0Y9ZixcC51m1yZfLM=
In-Reply-To: <kMOTJ.47117$m1S7.30500@fx36.iad>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 18:39 UTC

Am 02.03.2022 um 19:33 schrieb Scott Lurndal:
> Bonita Montero <Bonita.Montero@gmail.com> writes:
>> Am 02.03.2022 um 15:42 schrieb Scott Lurndal:
>>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>>> Am 02.03.2022 um 05:45 schrieb Lynn McGuire:
>>>>> On 2/28/2022 11: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.
>>>>>
>>>>> What is your definition of a modern language ?
>>>>
>>>> OOP,
>>>
>>> Simula, 1967.
>>>
>>>
>>>> RAII,
>>>
>>> ADA, 1980.
>>>
>>>> generic programming,
>>>
>>> ML, 1973.
>>>
>>>> functional programming,
>>>
>>> Lisp, 1970's.
>
>> We're talking about C++ vs. C.
>
> Lesen sie besser.
>
> "What is your definition of a modern language"

>> C isn't a modern language, no matter which standard.

> What is your definition of a modern language ?

That's C++ vs. C.
And it doesn't matter who came first. C++ is the only language
which combines nearly all of that features with the least possible
overhead (except thrown exceptions, but that's not significant for
the code).

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

<svoest$ase$1@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 19:00:45 +0000
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <svoest$ase$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 19:00:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f53ba3a84a7a054984956d0a53bb8af1";
logging-data="11150"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/G60+FofawjDJOyCZshfAzMdhKpr0HF1Y="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:8iKNJbP0SQ/LPmOrtNdcxprnDBs=
In-Reply-To: <87czj4jlwv.fsf@bsb.me.uk>
 by: Bart - Wed, 2 Mar 2022 19:00 UTC

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.

Then, by being present in the language, people like to use them
everywhere and for everything. Since templates work with source code, it
means libraries making extensive use of them, slowing down compilation.

(I wouldn't mind doing a better implementation myself, but for me not
it's not a requirement that comes up often. It's easie to just have 2-3
versions of that 6-line function.)

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

There are some nice ideas in FP but overall they are much harder to code
in for ordinary people, not helped by doing away with fundamentals such
as mutable variables, or loops.

Note that with 'generics', I'm talking about a feature where you write
one body of code, and that is instantiated multiple times, using
dedicated code for each type combination.

Another way of doing it is with dynamic or variant types, where the
/same/ body of code is executed even for different types. This is common
in scripting code, but it's also slower.

(This is how I deal with such things. I don't have built-in reduce, so
one was knocked up (see below), then this stuff is easy:

println reduce((max), (10,50,30,20,40)) # (max is built-in op)
println reduce((max), (1e100'000'000L, 1e-100'000'000L))
println reduce((max), ("BART"))
println reduce((+), ("One","Two","Three"))

Output is:

50
1.0e100000000
T
OneTwoThree

Creating 'list_max' etc is trivial. Note that you don't even need to be
aware of generics; it Just Works.

I'm currently incorporating such a dynamic type system into my systems
language.)

--------------
function reduce(op, L)=
case L.len
when 0 then
void
when 1 then
head(L) # borrowed from Haskell...
else
x:=head(L)
forall y in tail(L) do
x:=mapss(op, x,y)
od
x
esac
end

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

<svoevn$a67$2@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 20:02:20 +0100
Organization: A noiseless patient Spider
Lines: 5
Message-ID: <svoevn$a67$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 19:02:15 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="10439"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/vqG9xyVJCqui5QhrMIdu3gBWv4yfKcCU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:FGYWVe2Pbx/2voWsc9AyvV+ge84=
In-Reply-To: <svoest$ase$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 19:02 UTC

> Then, by being present in the language, people like to use them
> everywhere and for everything. Since templates work with source code, it
> means libraries making extensive use of them, slowing down compilation.

The higher productivity outweighs this my magnitudes.

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

<svof6k$cfi$1@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 11:05:56 -0800
Organization: A noiseless patient Spider
Lines: 69
Message-ID: <svof6k$cfi$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> <bnLTJ.29022$aT3.9637@fx09.iad>
<svocct$is5$3@dont-email.me> <kMOTJ.47117$m1S7.30500@fx36.iad>
<svodkd$t2l$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 19:05:57 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="d4a417dfd5e5fa43753e81c21b04ad49";
logging-data="12786"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bbVa3ncxqAYbcClA0QvnBEuR7d6EG+fE="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:Vz9U/xCGJpmoeZOJdQhlE/JqCvg=
In-Reply-To: <svodkd$t2l$1@dont-email.me>
Content-Language: en-US
 by: Chris M. Thomasson - Wed, 2 Mar 2022 19:05 UTC

On 3/2/2022 10:39 AM, Bonita Montero wrote:
> Am 02.03.2022 um 19:33 schrieb Scott Lurndal:
>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>> Am 02.03.2022 um 15:42 schrieb Scott Lurndal:
>>>> Bonita Montero <Bonita.Montero@gmail.com> writes:
>>>>> Am 02.03.2022 um 05:45 schrieb Lynn McGuire:
>>>>>> On 2/28/2022 11: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.
>>>>>>
>>>>>> What is your definition of a modern language ?
>>>>>
>>>>> OOP,
>>>>
>>>> Simula, 1967.
>>>>
>>>>
>>>>> RAII,
>>>>
>>>> ADA, 1980.
>>>>
>>>>> generic programming,
>>>>
>>>> ML, 1973.
>>>>
>>>>> functional programming,
>>>>
>>>> Lisp, 1970's.
>>
>>> We're talking about C++ vs. C.
>>
>> Lesen sie besser.
>>
>> "What is your definition of a modern language"
>
>
>
> >> C isn't a modern language, no matter which standard.
>
> > What is your definition of a modern language ?
>
> That's C++ vs. C.

Agreed. C++ is more "modern" than C for sure.

> And it doesn't matter who came first. C++ is the only language
> which combines nearly all of that features with the least possible
> overhead (except thrown exceptions, but that's not significant for
> the code).

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

<svofvi$kbb$1@dont-email.me>

  copy mid

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

  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: bc...@freeuk.com (Bart)
Newsgroups: comp.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Wed, 2 Mar 2022 19:19:14 +0000
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <svofvi$kbb$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 19:19:14 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f53ba3a84a7a054984956d0a53bb8af1";
logging-data="20843"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qDO3bF2K2BN8JHiZpJnVw8mYe0tcXlIU="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:x5nzvq32b/yVqK/3u3gMVZSu16Q=
In-Reply-To: <svobnq$d5p$1@dont-email.me>
 by: Bart - Wed, 2 Mar 2022 19:19 UTC

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

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

<877d9cjefn.fsf@bsb.me.uk>

  copy mid

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

  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: Wed, 02 Mar 2022 20:18:52 +0000
Organization: A noiseless patient Spider
Lines: 31
Message-ID: <877d9cjefn.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>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="7a95e9daa380f6bb604ae162b7ae9de3";
logging-data="15749"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Q28f5IszlPKeCu2/iDzEMsffAfzCjDzw="
Cancel-Lock: sha1:yy9SAY8sFIFKhlnF3Hy9o6PVl5U=
sha1:utyfEbEPy3nRMiqC/4jS2W9TZUs=
X-BSB-Auth: 1.1d378c0a7907bb05c42a.20220302201852GMT.877d9cjefn.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 2 Mar 2022 20:18 UTC

Bart <bc@freeuk.com> writes:

> 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,

And in practice.

> but look at how C++ does it for example, where I believe they are
> implemented via templates. Need I say more?

Yes, you should have said you don't like C++ templates up front.
Instead, you made a sweeping statement to hook naive people like me into
discussing it.

--
Ben.

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

<svok7m$oih$2@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 21:31:55 +0100
Organization: A noiseless patient Spider
Lines: 24
Message-ID: <svok7m$oih$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 20:31:50 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="267f58128df590709f4eff4ce2840dfa";
logging-data="25169"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1847Hquex3Gh68OHaiqvvM1cUlqpwSb3RE="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:FXNznhYzQaDHB/ffZ3HwtDZlEnQ=
In-Reply-To: <svoest$ase$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Wed, 2 Mar 2022 20:31 UTC

Show me sth. powerful like the following in any other language:

#include <iostream>
#include <type_traits>
#include <utility>
#include <tuple>

template<typename FirstArg, typename ... Args>
requires (sizeof ... (Args) == 0 || (std::is_convertible_v<Args,
FirstArg> && ...))
constexpr FirstArg multi_max( FirstArg firstArg, Args const &... args )
{ using namespace std;
FirstArg &max = firstArg;
auto findMax = [&]<size_t ... Is>( index_sequence<Is ...> iseq,
tuple<Args ...> tArgs )
{
((max = (FirstArg)get<Is>( tArgs ) > max ? (FirstArg)get<Is>( tArgs )
: max), ...);
};
findMax( make_index_sequence<sizeof ... (Args)>(), make_tuple( args ...
) );
return max;
}

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

<svokpo$tm8$1@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 21:41:27 +0100
Organization: A noiseless patient Spider
Lines: 193
Message-ID: <svokpo$tm8$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 2 Mar 2022 20:41:28 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="614e99140588b45c3f8540f9ac0ac77c";
logging-data="30408"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+YYx1jVTXCk32GoxTbb1APYfQYpY1FnTU="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:U318GYhG9ouiqfp7ZPiIYKYfsOM=
In-Reply-To: <svoest$ase$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Wed, 2 Mar 2022 20:41 UTC

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.

The older (and still perfectly good) explicit template syntax is not
exactly difficult either :

template<typename T>
T list_max1(const T& xs)
{ auto m = xs[0];
for (auto x : xs) {
m = (m > x) ? m : x;
}
return m;
}

(Of course, there are already standard library functions to find the
maximum of a container.)

> Then, by being present in the language, people like to use them
> everywhere and for everything. Since templates work with source code, it
> means libraries making extensive use of them, slowing down compilation.
>

Big template libraries /do/ take a lot of effort to compile - you are
correct there. That's why modules are being added to the language. (It
would have been nice to have had modules a couple of decades ago, but
better late than never.)

>
>> 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;
}

auto list_max(const auto & xs) {
return reduce_using(
[](auto a, auto b) { return (a > b) ? a : b; },
xs);
}

A slightly nicer (IMHO) functional programming style would have :

list_max = reduce_using(max)

where "reduce_using" returns a function. "list_max" is then called with
a list, in the same way. In C++, that would be:

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

auto list_max = reduce_using([](auto a, auto b)
{ return (a > b) ? a : b; });

(All these variants give the same object code from gcc.)

> There are some nice ideas in FP but overall they are much harder to code
> in for ordinary people, not helped by doing away with fundamentals such
> as mutable variables, or loops.

Mutable variables and loops are not fundamentals to programming - they
are fundamentals to /imperative/ programming. Functional programming
looks odd to people who have done nothing but imperative programming for
years. Imperative programming looks equally odd to people who have done
nothing but functional programming for years.

Imperative programming is a bit like cooking recipes - it's a series of
commands. Functional programming is more like mathematics, with a
series of definitions. Each has their advantages and disadvantages -
and thus many bigger programming languages support at least some aspects
of both styles.

>
> Note that with 'generics', I'm talking about a feature where you write
> one body of code, and that is instantiated multiple times, using
> dedicated code for each type combination.
>

Yes, I think that was clear. It is also known as early binding, or
compile-time generics.

> Another way of doing it is with dynamic or variant types, where the
> /same/ body of code is executed even for different types. This is common
> in scripting code, but it's also slower.

Indeed - also known as late binding or dynamic binding.

As usual, there are pros and cons to both systems.

>
> (This is how I deal with such things. I don't have built-in reduce, so
> one was knocked up (see below), then this stuff is easy:
>
>     println reduce((max), (10,50,30,20,40))       # (max is built-in op)
>     println reduce((max), (1e100'000'000L, 1e-100'000'000L))
>     println reduce((max), ("BART"))
>     println reduce((+),   ("One","Two","Three"))
>
> Output is:
>
>    50
>    1.0e100000000
>    T
>    OneTwoThree
>
> Creating 'list_max' etc is trivial. Note that you don't even need to be
> aware of generics; it Just Works.
>
> I'm currently incorporating such a dynamic type system into my systems
> language.)
>
> --------------
>     function reduce(op, L)=
>         case L.len
>         when 0 then
>             void
>         when 1 then
>             head(L)    # borrowed from Haskell...
>         else
>             x:=head(L)
>             forall y in tail(L) do
>                 x:=mapss(op, x,y)
>             od
>             x
>         esac
>     end
>
>

That's a perfectly reasonable way to handle this.

But it is not any more or less "trivial" than the C++ code or Haskell
code. The details are different, but not the principles.

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

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

  copy mid

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

  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: Wed, 02 Mar 2022 22:04:35 +0000
Organization: A noiseless patient Spider
Lines: 81
Message-ID: <87pmn4huz0.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>
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
Injection-Info: reader02.eternal-september.org; posting-host="7a95e9daa380f6bb604ae162b7ae9de3";
logging-data="4410"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/yIpklwtHoTxx52q+ysaNAAE51yvoBSAg="
Cancel-Lock: sha1:eXTIKmMF6PYrll7It9nvrkoAGAk=
sha1:78CYpL1+12zi2lr0tK+wYIk1N7U=
X-BSB-Auth: 1.4186fd67e187cfc21f62.20220302220435GMT.87pmn4huz0.fsf@bsb.me.uk
 by: Ben Bacarisse - Wed, 2 Mar 2022 22:04 UTC

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.

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

--
Ben.

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

<svou8p$7qd$1@dont-email.me>

  copy mid

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

  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: Wed, 2 Mar 2022 23:23:04 +0000
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <svou8p$7qd$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; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 2 Mar 2022 23:23:05 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cdd9ae9ac835544bf069b74349a5db5b";
logging-data="8013"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/cVou5OlTRjvn7JA3gq+FN1G2MFmdXqKk="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:DD4P5YZEHX8tK5YYDG8+hpup8es=
In-Reply-To: <87pmn4huz0.fsf@bsb.me.uk>
 by: Bart - Wed, 2 Mar 2022 23:23 UTC

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.

But it is easy to tweak, eg. return an index to the largest element instead.

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

The examples were clearly mainly for my benefit in showing that C++ is
not that bad after all.

My quibble would be that this requires a function to be passed, but your
example (and mine) could pass operators too.

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

<a1cd9d35-b256-4e64-b958-f5d9b15f9410n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:15c1:b0:649:1a2b:4850 with SMTP id o1-20020a05620a15c100b006491a2b4850mr17512643qkm.525.1646264708639;
Wed, 02 Mar 2022 15:45:08 -0800 (PST)
X-Received: by 2002:a37:6c45:0:b0:478:a755:8845 with SMTP id
h66-20020a376c45000000b00478a7558845mr17446455qkc.362.1646264708481; Wed, 02
Mar 2022 15:45:08 -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: Wed, 2 Mar 2022 15:45:08 -0800 (PST)
In-Reply-To: <svou8p$7qd$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:785a:abd3:fbf3:a8f1;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:785a:abd3:fbf3:a8f1
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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a1cd9d35-b256-4e64-b958-f5d9b15f9410n@googlegroups.com>
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Wed, 02 Mar 2022 23:45:08 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 48
 by: Malcolm McLean - Wed, 2 Mar 2022 23:45 UTC

On Wednesday, 2 March 2022 at 23:23:46 UTC, Bart wrote:
> 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.
>
> But it is easy to tweak, eg. return an index to the largest element instead.
> >> 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.
>
Not so much an oversight, as a weakness of the for (variable : container) syntax.
Whilst you usually need to iterate over a collection of objects, applying the
same operation to each one, the exceptions are not all that uncommon. In this
case the first element needs to be special-cased. That's very easy with counter-
based C-style for loops.

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

<877d9bhpb0.fsf@bsb.me.uk>

  copy mid

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

  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 00:06:59 +0000
Organization: A noiseless patient Spider
Lines: 83
Message-ID: <877d9bhpb0.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>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4aa79f9a4708fd38aa26eaecc64b4ca3";
logging-data="24571"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vrN/glyVCwZ4ivf8JpNJ0Wr1XxrBizE0="
Cancel-Lock: sha1:YXPEw16yvgGqR1blnb7EC5DUlCk=
sha1:8+VVNNDbkgPGNfmwLYoorO8EY5g=
X-BSB-Auth: 1.61c76957b8c502a83b7d.20220303000659GMT.877d9bhpb0.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 3 Mar 2022 00:06 UTC

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.

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.

--
Ben.

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

<46685cb7-b2cd-4a50-80b2-94b4d79d0a50n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a37:bf45:0:b0:5f1:924c:23d0 with SMTP id p66-20020a37bf45000000b005f1924c23d0mr18018151qkf.374.1646268869931;
Wed, 02 Mar 2022 16:54:29 -0800 (PST)
X-Received: by 2002:a05:622a:198b:b0:2de:57e2:d08e with SMTP id
u11-20020a05622a198b00b002de57e2d08emr25721736qtc.588.1646268869776; Wed, 02
Mar 2022 16:54:29 -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: Wed, 2 Mar 2022 16:54:29 -0800 (PST)
In-Reply-To: <877d9bhpb0.fsf@bsb.me.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:785a:abd3:fbf3:a8f1;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:785a:abd3:fbf3:a8f1
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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <46685cb7-b2cd-4a50-80b2-94b4d79d0a50n@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 00:54:29 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 96
 by: Malcolm McLean - Thu, 3 Mar 2022 00:54 UTC

On Thursday, 3 March 2022 at 00:07:33 UTC, 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.
>
> 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.
>
Here's the C version.
int reduce_using(void *x, int N, size_t elsize, void (*op)(void *context, void *dest, const void *a, const void *b), void *context)
{ void *temp = malloc(elsize);
int i;

if (!temp)
return -1;
for (i = 1; i < N, i++)
{
(*op)(context, temp, x,((unsigned char *) x) + i * elsize);
memcpy(x, temp, elsize);
}

free(temp);
return 0;
}

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.

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

<svp5qm$ls3$1@dont-email.me>

  copy mid

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

  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: lynnmcgu...@gmail.com (Lynn McGuire)
Newsgroups: comp.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Wed, 2 Mar 2022 19:32:04 -0600
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <svp5qm$ls3$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 3 Mar 2022 01:32:06 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="83611accec6d17baf28190daea5ac1c6";
logging-data="22403"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+JmGoxdgEZuEZGF8iWr4Ds"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:9kQDCfhkvGuPqM1OK0O8Obx/4M8=
In-Reply-To: <svofvi$kbb$1@dont-email.me>
Content-Language: en-US
 by: Lynn McGuire - Thu, 3 Mar 2022 01:32 UTC

On 3/2/2022 1: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

Well, that is a bummer. That means that I will have to explicitly type
everything int64 when we move to Win64.

I already knew that I was going to have to change all the integer types
in my Fortran code integer*8 but I expected 64 bit C to treat int at 64 bit.

Lynn

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

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

  copy mid

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

  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 01:59:04 +0000
Organization: A noiseless patient Spider
Lines: 144
Message-ID: <87pmn3g5jr.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>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="4aa79f9a4708fd38aa26eaecc64b4ca3";
logging-data="32026"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5diiUbcDsG8Ky1WzBK6qLrcifPpLhziY="
Cancel-Lock: sha1:5pbY/GucaoM+NnH4RIodZTxJcBk=
sha1:9ajyZHFTo6zZ/jkWgYpOuurhfLw=
X-BSB-Auth: 1.24a513f583aa4c2c2813.20220303015904GMT.87pmn3g5jr.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 3 Mar 2022 01:59 UTC

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

> On Thursday, 3 March 2022 at 00:07:33 UTC, 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.
>>
>> 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;
>> }

I did not write this! Your posting has messed up my indentation and
spacing.

>> There is a proposal for pattern matching in C++ (using a new keyword
>> "inspect"), but I don't think it handles iterables.
>>
> Here's the C version.
>
> int reduce_using(void *x, int N, size_t elsize, void (*op)(void *context, void *dest, const void *a, const void *b), void *context)
> {
> void *temp = malloc(elsize);
> int i;
>
> if (!temp)
> return -1;
> for (i = 1; i < N, i++)
> {
> (*op)(context, temp, x,((unsigned char *) x) + i * elsize);
> memcpy(x, temp, elsize);
> }
>
> free(temp);
> return 0;
> }

Did you intend the interface to overwrite the first element of the input
array? That's not all the same kind of function!

And it does not (indeed cannot) return the calculated result, nor does
it work for anything but arrays, whereas the C++ version (once
corrected) will work for maps and set and linked lists and so on.

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;

* removed the context pointer as this should really only be used for
pure functions;

* simplified the address calculation using a variably modified type (not
a VLA);

* required the caller provide a separate destination (though they could
emulate your interface by pointing to the first array element).

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

--
Ben.

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

<fsq5fi-0hh.ln1@paranoia.mcleod-schmidt.id.au>

  copy mid

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

  copy link   Newsgroups: comp.programming.threads comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news.szaf.org!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: grschm...@acm.org (Gary R. Schmidt)
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 14:56:54 +1100
Lines: 56
Message-ID: <fsq5fi-0hh.ln1@paranoia.mcleod-schmidt.id.au>
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>
<svp5qm$ls3$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: individual.net C/VxRgJvdCKJ3sL0mfaNhA4nyBls7yrWgij0AXZuttJajLYmU=
X-Orig-Path: paranoia.mcleod-schmidt.id.au!not-for-mail
Cancel-Lock: sha1:hb5Zrgx5mwkKPPtIC7jKUXtJF38=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Betterbird/91.6.1
Content-Language: en-AU
In-Reply-To: <svp5qm$ls3$1@dont-email.me>
X-Clacks-Overhead: GNU Terry Pratchett
 by: Gary R. Schmidt - Thu, 3 Mar 2022 03:56 UTC

On 03/03/2022 12:32, Lynn McGuire wrote:
> On 3/2/2022 1: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
>
> Well, that is a bummer.  That means that I will have to explicitly type
> everything int64 when we move to Win64.
>
> I already knew that I was going to have to change all the integer types
> in my Fortran code integer*8 but I expected 64 bit C to treat int at 64
> bit.

On 64-bit Linux, the default gcc instance builds 64-bit binaries, using
the I32LP64 model.

The Alpha was nice, it's default was ILP64.

Winderrs is worse, it use IL32P64, I'll leave dealing with the
assumptions C programmers have made over the decades to your imagination.

I've been using my own set of typedefs to control things since the early
1990's, and being hard on myself and occasional minions about not using
"int" anywhere. Edit one header file and everything is as big/small as
you need/want. :-)

Cheers,
Gary B-)

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

<cb5b8e98-5ff9-41eb-a1a8-41254789f996n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:2889:b0:663:8d24:8cad with SMTP id j9-20020a05620a288900b006638d248cadmr780497qkp.662.1646308801224;
Thu, 03 Mar 2022 04:00:01 -0800 (PST)
X-Received: by 2002:a05:6214:ac1:b0:435:3d5e:5ba9 with SMTP id
g1-20020a0562140ac100b004353d5e5ba9mr987189qvi.80.1646308801062; Thu, 03 Mar
2022 04:00:01 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!3.us.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 04:00:00 -0800 (PST)
In-Reply-To: <87pmn3g5jr.fsf@bsb.me.uk>
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> <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>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cb5b8e98-5ff9-41eb-a1a8-41254789f996n@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 12:00:01 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 161
 by: Malcolm McLean - Thu, 3 Mar 2022 12:00 UTC

On Thursday, 3 March 2022 at 01:59:40 UTC, Ben Bacarisse wrote:
> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>
> > On Thursday, 3 March 2022 at 00:07:33 UTC, 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.
> >>
> >> 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;
> >> }
> I did not write this! Your posting has messed up my indentation and
> spacing.
> >> There is a proposal for pattern matching in C++ (using a new keyword
> >> "inspect"), but I don't think it handles iterables.
> >>
> > Here's the C version.
> >
> > int reduce_using(void *x, int N, size_t elsize, void (*op)(void *context, void *dest, const void *a, const void *b), void *context)
> > {
> > void *temp = malloc(elsize);
> > int i;
> >
> > if (!temp)
> > return -1;
> > for (i = 1; i < N, i++)
> > {
> > (*op)(context, temp, x,((unsigned char *) x) + i * elsize);
> > memcpy(x, temp, elsize);
> > }
> >
> > free(temp);
> > return 0;
> > }
> Did you intend the interface to overwrite the first element of the input
> array? That's not all the same kind of function!
>
Yes. But that was probably a mistake.
>
> And it does not (indeed cannot) return the calculated result, nor does
> it work for anything but arrays, whereas the C++ version (once
> corrected) will work for maps and set and linked lists and so on.
>
But arrays are by far and away the most common data structure for
things thta reduce makes sense for.
> 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.
>
> * 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.
> * 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.
> * required the caller provide a separate destination (though they could
> emulate your interface by pointing to the first array element).
>
I was thinkng that if you reduce an array, you turn it into an array of one element.
However you can't alias the pointers to the comparison function without
documenting it. Otherwise someone could write to a dest member, then
access it through the const * to a.
>
> > 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.

That's a huge advantage of C. Except for pointers, if you know another language,
you know enough to be a sucessful C programmer without learning much
at all.

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

<svqe8o$5nl$2@dont-email.me>

  copy mid

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

  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 14:02:16 +0100
Organization: A noiseless patient Spider
Lines: 38
Message-ID: <svqe8o$5nl$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>
<svp5qm$ls3$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 13:02:16 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="498b7a2828220d39959d75bae7cf64b6";
logging-data="5877"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19jShf2mY3/11UiTI/ITSbmRD/2u+12lzw="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:nK+nr1lw8UcmCRgGLOqCIln56JM=
In-Reply-To: <svp5qm$ls3$1@dont-email.me>
Content-Language: de-DE
 by: Bonita Montero - Thu, 3 Mar 2022 13:02 UTC

Am 03.03.2022 um 02:32 schrieb Lynn McGuire:
> On 3/2/2022 1: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
>
> Well, that is a bummer.  That means that I will have to explicitly type
> everything int64 when we move to Win64.

If you need a scalar type that always matches the with of
the general purpose integer-registers use size_t or ptrdiff_t.

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

<svqi6n$1ccc$1@gioia.aioe.org>

  copy mid

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

  copy link   Newsgroups: comp.programming.threads 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.programming.threads,comp.lang.c
Subject: Re: Linus Torvalds prepares to move the Linux kernel to modern C
Date: Thu, 3 Mar 2022 15:09:28 +0100
Organization: Aioe.org NNTP Server
Message-ID: <svqi6n$1ccc$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>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="45452"; 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
Content-Language: en-US
X-Notice: Filtered by postfilter v. 0.9.2
 by: Manfred - Thu, 3 Mar 2022 14:09 UTC

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?

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

<svqifq$97v$1@dont-email.me>

  copy mid

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

  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 15:14:18 +0100
Organization: A noiseless patient Spider
Lines: 39
Message-ID: <svqifq$97v$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:14:18 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="498b7a2828220d39959d75bae7cf64b6";
logging-data="9471"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/atIkdjbfq25GZ0VBaJ8xBxnwwhw7/vhY="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.6.1
Cancel-Lock: sha1:RHBc86L834qekgzm9QTOtq3qPIU=
In-Reply-To: <svqi6n$1ccc$1@gioia.aioe.org>
Content-Language: de-DE
 by: Bonita Montero - Thu, 3 Mar 2022 14:14 UTC

Am 03.03.2022 um 15:09 schrieb Manfred:
> 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?

Even if an int is only 32 bit that's too much. ^^

Pages:1234
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor