Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Without life, Biology itself would be impossible.


devel / comp.lang.c / you think rust may outthrone c?

SubjectAuthor
* you think rust may outthrone c?fir
`* Re: you think rust may outthrone c?Blue-Maned_Hawk
 +- Re: you think rust may outthrone c?jak
 +* Re: you think rust may outthrone c?fir
 |`- Re: you think rust may outthrone c?fir
 +* Re: you think rust may outthrone c?rek2 hispagatos
 |`* Re: you think rust may outthrone c?Kaz Kylheku
 | `* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  +* Re: you think rust may outthrone c?Scott Lurndal
 |  |`* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | +- Re: you think rust may outthrone c?Kaz Kylheku
 |  | +* Re: you think rust may outthrone c?Bart
 |  | |`* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | +* Re: you think rust may outthrone c?Bart
 |  | | |+* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | ||`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | || `- Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |`* Re: you think rust may outthrone c?David Brown
 |  | | | `* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |  +* Re: you think rust may outthrone c?David Brown
 |  | | |  |`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |  | `- Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |  `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |   `* Re: you think rust may outthrone c?Kalevi Kolttonen
 |  | | |    `* Re: you think rust may outthrone c?David Brown
 |  | | |     +* Re: you think rust may outthrone c?Scott Lurndal
 |  | | |     |`- Re: you think rust may outthrone c?Keith Thompson
 |  | | |     `* Re: you think rust may outthrone c?Keith Thompson
 |  | | |      +- Re: you think rust may outthrone c?David Brown
 |  | | |      `* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |       `* Re: you think rust may outthrone c?David Brown
 |  | | |        `* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |         `* Re: you think rust may outthrone c?David Brown
 |  | | |          +- Re: you think rust may outthrone c?fir
 |  | | |          +* Re: you think rust may outthrone c?fir
 |  | | |          |`* Re: you think rust may outthrone c?fir
 |  | | |          | `- Re: you think rust may outthrone c?fir
 |  | | |          `* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |           `* Re: you think rust may outthrone c?Bart
 |  | | |            +* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            |`* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            | +* Re: you think rust may outthrone c?David Brown
 |  | | |            | |+* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            | ||+* Re: you think rust may outthrone c?David Brown
 |  | | |            | |||+* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            | ||||`* Re: you think rust may outthrone c?Tim Rentsch
 |  | | |            | |||| `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            | |||`* Re: you think rust may outthrone c?Bart
 |  | | |            | ||| +- Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            | ||| `- Re: you think rust may outthrone c?David Brown
 |  | | |            | ||`- Re: you think rust may outthrone c?Scott Lurndal
 |  | | |            | |`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |            | | +- Re: you think rust may outthrone c?David Brown
 |  | | |            | | `* Re: you think rust may outthrone c?jak
 |  | | |            | |  `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |            | |   +- Re: you think rust may outthrone c?jak
 |  | | |            | |   `- Re: you think rust may outthrone c?Tim Rentsch
 |  | | |            | `* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            |  `* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |            |   +- Re: you think rust may outthrone c?David Brown
 |  | | |            |   `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |            `* Re: you think rust may outthrone c?David Brown
 |  | | |             `* Re: you think rust may outthrone c?fir
 |  | | |              +* Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              |`* Re: you think rust may outthrone c?David Brown
 |  | | |              | +* Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | |+* Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | ||+- Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | ||+* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |              | |||`- Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              | ||`- Re: you think rust may outthrone c?fir
 |  | | |              | |`- Re: you think rust may outthrone c?Bart
 |  | | |              | `- Re: you think rust may outthrone c?Chris M. Thomasson
 |  | | |              `* Re: you think rust may outthrone c?fir
 |  | | |               `* Re: you think rust may outthrone c?Bart
 |  | | |                +* Re: you think rust may outthrone c?Keith Thompson
 |  | | |                |+* Re: you think rust may outthrone c?Bart
 |  | | |                ||+* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                |||`* Re: you think rust may outthrone c?Bart
 |  | | |                ||| +- Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                ||| +* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| |+* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||+- Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||`* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| || `* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||  `* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| ||   +* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||   |`* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| ||   | `* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||   |  `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| ||   `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                ||| ||    `- Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| |+* Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||+* Re: you think rust may outthrone c?Ike Naar
 |  | | |                ||| |||`- Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||+* Re: you think rust may outthrone c?David Brown
 |  | | |                ||| |||`* Re: you think rust may outthrone c?Bart
 |  | | |                ||| ||| `- Re: you think rust may outthrone c?David Brown
 |  | | |                ||| ||`* Re: you think rust may outthrone c?Ben Bacarisse
 |  | | |                ||| || +- Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                ||| || +* Re: you think rust may outthrone c?Malcolm McLean
 |  | | |                ||| || `* Re: you think rust may outthrone c?Bart
 |  | | |                ||| |`* Re: you think rust may outthrone c?Scott Lurndal
 |  | | |                ||| `* Re: you think rust may outthrone c?Keith Thompson
 |  | | |                ||`- Re: you think rust may outthrone c?Keith Thompson
 |  | | |                |`* Re: you think rust may outthrone c?Kaz Kylheku
 |  | | |                `* Re: you think rust may outthrone c?fir
 |  | | +* Yeah, C is harder than many programming languages. Your point? (Was: you think Kenny McCormack
 |  | | +* Re: you think rust may outthrone c?Po Lu
 |  | | `* Re: you think rust may outthrone c?Kaz Kylheku
 |  | +* Re: you think rust may outthrone c?David Brown
 |  | `- Re: you think rust may outthrone c?Po Lu
 |  `* Re: you think rust may outthrone c?Anton Shepelev
 `* Re: you think rust may outthrone c?Bonita Montero

Pages:123456789101112131415161718192021222324252627282930313233343536373839
Re: you think rust may outthrone c?

<b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:170f:b0:403:e743:cc77 with SMTP id h15-20020a05622a170f00b00403e743cc77mr13578qtk.6.1690460133073;
Thu, 27 Jul 2023 05:15:33 -0700 (PDT)
X-Received: by 2002:a9d:6f09:0:b0:6b9:99ab:7f25 with SMTP id
n9-20020a9d6f09000000b006b999ab7f25mr7397929otq.6.1690460131997; Thu, 27 Jul
2023 05:15:31 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.cmpublishers.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 27 Jul 2023 05:15:31 -0700 (PDT)
In-Reply-To: <u9tko8$1s9cs$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:6c83:9fbc:2db2:919;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:6c83:9fbc:2db2:919
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 27 Jul 2023 12:15:33 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2477
 by: Malcolm McLean - Thu, 27 Jul 2023 12:15 UTC

On Thursday, 27 July 2023 at 12:34:50 UTC+1, David Brown wrote:
>
> I can't answer for Scott, but for me it could be int16_t, int32_t or
> int64_t, depending on the context - I make sure I use appropriate types
> for the calculations I need, balanced with the efficiency requirements
> on the particular target.
>
Take this code

void filter(float *out, const float *in, size_t N, const float *filter, size_t Nf)
{ mysterytype_t index;
size_t i, j;

for ( i =0; i < N; i=i++)
{
out[i] = 0.0f;
for(j = 0, index = i - Nf/2; j < Nf; j++, index++)
{
if (index < 0 || index >= N)
contiue;
out[index] += in[i] * filter[j];
}
}
}

What would you use for mysterytype_t?

Re: you think rust may outthrone c?

<u9tqj6$1sr5t$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 15:14:13 +0200
Organization: A noiseless patient Spider
Lines: 53
Message-ID: <u9tqj6$1sr5t$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 13:14:14 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a73b140d724915d3073e7cf4d4b344b4";
logging-data="1993917"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19VXx1O2se8SrD0OiAo4RzkisMUkyx2Xc8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:kNzwN3gYgYm/jR7tRgFznBdj3UE=
Content-Language: en-GB
In-Reply-To: <b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com>
 by: David Brown - Thu, 27 Jul 2023 13:14 UTC

On 27/07/2023 14:15, Malcolm McLean wrote:
> On Thursday, 27 July 2023 at 12:34:50 UTC+1, David Brown wrote:
>>
>> I can't answer for Scott, but for me it could be int16_t, int32_t or
>> int64_t, depending on the context - I make sure I use appropriate types
>> for the calculations I need, balanced with the efficiency requirements
>> on the particular target.
>>
> Take this code
>
> void filter(float *out, const float *in, size_t N, const float *filter, size_t Nf)
> {
> mysterytype_t index;
> size_t i, j;
>
> for ( i =0; i < N; i=i++)
> {
> out[i] = 0.0f;
> for(j = 0, index = i - Nf/2; j < Nf; j++, index++)
> {
> if (index < 0 || index >= N)
> contiue;
> out[index] += in[i] * filter[j];
> }
> }
> }
>
> What would you use for mysterytype_t?
>

I wouldn't. I'd start with index at 0, and adjust the rest of the
variables to suit. And I would not have partial filter application at
the ends of the data sample - there's no point in making the inner loop
significantly slower just to generate incorrect (potentially wildly
incorrect) and useless results there. The useful output will of size N
- Nf, not N.

If I really had to include these wrong results, I'd do them separately
from the main loop - usually with such filters, speed is important and
you want the inner loop to work neatly - with automatic SIMD processing
if the compiler and target support it.

If I /really/ had to include the wrong results, and /really/ wanted to
do them at the same time, I'd take advantage of the fact that (2N + Nf)
<= SIZE_MAX to know what types I could safely use in the arithmetic.
(If the various arrays could overlap, the algorithm would have to be
changed dramatically. Oh, and I'd remember that this is the 21st
century, and add "restrict" to the parameters.)

Re: you think rust may outthrone c?

<u9trgp$1stmg$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.chmurka.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 14:30:01 +0100
Organization: A noiseless patient Spider
Lines: 86
Message-ID: <u9trgp$1stmg$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 13:30:01 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f6c6f94519e1a2521af762b44f8b9876";
logging-data="1996496"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0UJHko6nf0zJFKzghGdv8ZySJHTrRCXI="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:GmcEqDpQbodELW7mx3iLsjLgw2w=
In-Reply-To: <u9tko8$1s9cs$1@dont-email.me>
 by: Bart - Thu, 27 Jul 2023 13:30 UTC

On 27/07/2023 12:34, David Brown wrote:
> On 26/07/2023 23:07, Bart wrote:
> /Your/ assertion was that half the existing programs would break if
> "int" were 64 bits instead of the more common 32 bits. You have failed
> to produce the slightest justification for that. It is irrelevant
> whether Scott or anyone else knows of programs that might have issues
> with such a change. And Scott did not in any way say that you were
> wrong in your claim - he just noted that you are apparently unable to
> justify it. (I, for one, have little idea if you are right or wrong
> because I am not familiar with the vast majority of C code written. I
> don't believe you know any better either - but we await your evidence.)
>

Common sense and experience ought to tell you that I'm probably right.

But what evidence exactly do you want?

Either there is going to be a big problem, or there isn't, but suppose
you need to decide whether you're going to make 'int' 64 bits. What
would /you/ do?

Do /you/ think there will be many problems with programs breaking,
because there is either a deliberate or inadvertent reliance on int
being 32 bits?

'int' is probably the most-used C type in C code.

Time to put your money on this again! Or will you just go for it
because, after all, there is no real evidence that anything will go wrong?

Note that MS probably left 'long' as 32 bits, when 'int' became 32 bits
too, for similar reasons.

(I suspect I'm the only one here who has attempted to make a C with a
64-bit int, to try it out. It didn't work, but there were many other
reasons for that.

That the C library still used 32 bits, even if I changed the APIs to
ensure that was 'int' was the 32-bit equivalent, may have been one
factor why the experiment wouldn't work unless I also recompiled the
library from source using 64-bit int.)

> I think most C programmers have come across variants and alternatives to
> "int32_t" that have much the same meaning. But these alternatives
> typically come from either:
>
> 1. Code with a history from before C99 and the <stdint.h> types.
> 2. Code written to work with pre-C99 toolchains.
> 3. Newer code referring to or using type 1 or 2 code.
> 4. Code that uses different names to distinguish types for different
> purposes, perhaps using more advanced linters to check usage in a
> stronger manner than C compilers typically support.

You're not going to be convinced are you, no matter how many examples I
might come up with!

There must always be /some other/ reason why somebody defines a new
alias on top of `int32_t`, because there's hardly going to be a comment
that says it's because they are ugly or long-winded.

BTW here's an extract from a Raylib module:

unsigned int defaultFontData[512] = {
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00200020, 0x0001b000, 0x00000000, 0x00000000,
0x8ef92520, 0x00020a00, 0x7dbe8000, 0x1f7df45f,

I guess 'int' had better be 32 bits in this case!

> I have only ever heard of one person who actively chooses some variant
> other than the <stdint.h> types such as int32_t from a free choice,
> without any particular reason or justification other than that they
> think the identifier "int32_t" is ugly. You can guess who that
person is.

If you're generating C code, then those also take up more space for no
reason. There I will use short forms like 'i32'.

(Actually, my generated C code doesn't use any standard headers, so that
`int32_t` doesn't exist, and the standard header would anyway only
define it on top of `int`.)

Re: you think rust may outthrone c?

<6783b3a8-b11f-4159-a4d2-165fd2bf8c01n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:6698:b0:76a:d9a6:a8d0 with SMTP id qh24-20020a05620a669800b0076ad9a6a8d0mr11272qkn.1.1690464675256;
Thu, 27 Jul 2023 06:31:15 -0700 (PDT)
X-Received: by 2002:a9d:6758:0:b0:6b7:45a8:a80c with SMTP id
w24-20020a9d6758000000b006b745a8a80cmr7376838otm.3.1690464674888; Thu, 27 Jul
2023 06:31:14 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 27 Jul 2023 06:31:14 -0700 (PDT)
In-Reply-To: <u9tqj6$1sr5t$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:6c83:9fbc:2db2:919;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:6c83:9fbc:2db2:919
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com> <u9tqj6$1sr5t$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6783b3a8-b11f-4159-a4d2-165fd2bf8c01n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 27 Jul 2023 13:31:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 4278
 by: Malcolm McLean - Thu, 27 Jul 2023 13:31 UTC

On Thursday, 27 July 2023 at 14:14:30 UTC+1, David Brown wrote:
> On 27/07/2023 14:15, Malcolm McLean wrote:
> > On Thursday, 27 July 2023 at 12:34:50 UTC+1, David Brown wrote:
> >>
> >> I can't answer for Scott, but for me it could be int16_t, int32_t or
> >> int64_t, depending on the context - I make sure I use appropriate types
> >> for the calculations I need, balanced with the efficiency requirements
> >> on the particular target.
> >>
> > Take this code
> >
> > void filter(float *out, const float *in, size_t N, const float *filter, size_t Nf)
> > {
> > mysterytype_t index;
> > size_t i, j;
> >
> > for ( i =0; i < N; i=i++)
> > {
> > out[i] = 0.0f;
> > for(j = 0, index = i - Nf/2; j < Nf; j++, index++)
> > {
> > if (index < 0 || index >= N)
> > contiue;
> > out[index] += in[i] * filter[j];
> > }
> > }
> > }
> >
> > What would you use for mysterytype_t?
> >
> I wouldn't. I'd start with index at 0, and adjust the rest of the
> variables to suit. And I would not have partial filter application at
> the ends of the data sample - there's no point in making the inner loop
> significantly slower just to generate incorrect (potentially wildly
> incorrect) and useless results there. The useful output will of size N
> - Nf, not N.
>
> If I really had to include these wrong results, I'd do them separately
> from the main loop - usually with such filters, speed is important and
> you want the inner loop to work neatly - with automatic SIMD processing
> if the compiler and target support it.
>
What to do with the sample edges is one of those problems which doesn't
have a good answer. Here the samples beyond the input are set to zero.
Which is often what you want.
You Fourier transform the signal if speed is a problem.

But yes, there's a lot you could do to optimise this simple filter code. But
that's not the job.
>
> If I /really/ had to include the wrong results, and /really/ wanted to
> do them at the same time, I'd take advantage of the fact that (2N + Nf)
> <= SIZE_MAX to know what types I could safely use in the arithmetic.
> (If the various arrays could overlap, the algorithm would have to be
> changed dramatically. Oh, and I'd remember that this is the 21st
> century, and add "restrict" to the parameters.)
>
But you haven't answered the question, which is a victory for Bart. There
is no type we can use for mysterytype_t which is really satisfactory.

Re: you think rust may outthrone c?

<ESuwM.246845$GMN3.106013@fx16.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx16.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: you think rust may outthrone c?
Newsgroups: comp.lang.c
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com> <u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com> <u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad> <u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad> <u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
Lines: 38
Message-ID: <ESuwM.246845$GMN3.106013@fx16.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Thu, 27 Jul 2023 14:07:32 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Thu, 27 Jul 2023 14:07:32 GMT
X-Received-Bytes: 2741
 by: Scott Lurndal - Thu, 27 Jul 2023 14:07 UTC

David Brown <david.brown@hesbynett.no> writes:
>On 26/07/2023 23:07, Bart wrote:

>> >> * 64-bit ints would kick the signed overflow can much further down the
>
>(I actually agree that there would have been many advantages to making
>"int" 64-bit on 64-bit systems. But there would also have been a key
>disadvantage - it would make it very inconvenient to get 16-bit and
>32-bit types with standard C integer types.)

The concerns at the time revolved around the additional memory
required to make all 'int' (and enum, etc) 64-bit.

>
>> >
>> > I, personally, haven't experienced any issues with signed overflow;>
>> primarily because I very seldom actually use 'int' types in C or C++
>> > myself.
>>
>> OK. Think about /why/ you avoid using 'int' types, then think about
>> those who do, which is going to be in the millions. All of those, of any
>> range of skill and experience, will of course have carefully weighed the
>> pros and cons of their decisions, and will have factored in the possible
>> switch of `int` to a 64-bit type in the future.
>>
>> (I'd be curious as to what actual types you use where the problems of
>> overflow vanish, but never mind, it's going to be just another
>> belittling remark.)
>>
>
>I can't answer for Scott, but for me it could be int16_t, int32_t or
>int64_t, depending on the context - I make sure I use appropriate types
>for the calculations I need, balanced with the efficiency requirements
>on the particular target.

As I otherwise noted, I very seldom need signed integers. When I do,
I use the appropriate type based on context as you do.

Re: you think rust may outthrone c?

<u9tu9f$1t5jb$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 16:17:18 +0200
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <u9tu9f$1t5jb$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com>
<u9tqj6$1sr5t$1@dont-email.me>
<6783b3a8-b11f-4159-a4d2-165fd2bf8c01n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 14:17:19 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a73b140d724915d3073e7cf4d4b344b4";
logging-data="2004587"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HxrpkjAlHrD2ZAjo/A0rZZuZ67xgfR24="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:g6DtFtThAvJMJ5TBfxQgL4W1f2s=
Content-Language: en-GB
In-Reply-To: <6783b3a8-b11f-4159-a4d2-165fd2bf8c01n@googlegroups.com>
 by: David Brown - Thu, 27 Jul 2023 14:17 UTC

On 27/07/2023 15:31, Malcolm McLean wrote:

> But you haven't answered the question, which is a victory for Bart. There
> is no type we can use for mysterytype_t which is really satisfactory.
>

If you wanted an artificial question to provoke an answer of "there is
no good answer", why not just ask for a C type that is guaranteed to
have more than 64 bits?

My answer to your question was, I think, a lot more informative - it
showed that in realistic situations when there is apparently a problem
picking a type, it is more likely that there is a problem with the code
or algorithm, or at least better ways to formulate it.

However, if you were to simply ask "what type should you use in C for 65
bits signed", there is no suitable type in standard C. You could use
common 64-bit compiler extensions such as __int128 or similar names, or
you would have to build one manually from two 64-bit integer types. But
this is nothing new or surprising to anyone.

Re: you think rust may outthrone c?

<u9u040$1tbdh$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: david.br...@hesbynett.no (David Brown)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 16:48:32 +0200
Organization: A noiseless patient Spider
Lines: 195
Message-ID: <u9u040$1tbdh$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 27 Jul 2023 14:48:32 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="a73b140d724915d3073e7cf4d4b344b4";
logging-data="2010545"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+ITnShDeBIyyxvIuq8HDda2C1nj38RC74="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101
Thunderbird/60.6.1
Cancel-Lock: sha1:1RU47mC9NyU73gPEXiyqoN92z3M=
In-Reply-To: <u9trgp$1stmg$1@dont-email.me>
Content-Language: en-GB
 by: David Brown - Thu, 27 Jul 2023 14:48 UTC

On 27/07/2023 15:30, Bart wrote:
>
> On 27/07/2023 12:34, David Brown wrote:
> > On 26/07/2023 23:07, Bart wrote:
> > /Your/ assertion was that half the existing programs would break if
> > "int" were 64 bits instead of the more common 32 bits.  You have failed
> > to produce the slightest justification for that.  It is irrelevant
> > whether Scott or anyone else knows of programs that might have issues
> > with such a change.  And Scott did not in any way say that you were
> > wrong in your claim - he just noted that you are apparently unable to
> > justify it.  (I, for one, have little idea if you are right or wrong
> > because I am not familiar with the vast majority of C code written.  I
> > don't believe you know any better either - but we await your evidence.)
> >
>
> Common sense and experience ought to tell you that I'm probably right.
>

No, it does not. Seriously. There's a great deal of C code that
assumes "int" is at least 32-bit - for a lot of it, the assumption is
reasonable (due to other constraints, such as using Windows or *nix API
calls), and for some the code could have been more portable without such
assumptions.

However, I think it is actually rare to assume a /maximum/ size for int.

The one common case might be malloc'ing an array of int using a style of
"int * p = malloc(N * 4)" rather than "int * p = malloc(N *
sizeof(int))" or "int * p = malloc(N * sizeof(*p))".

Do over half of C programs have such allocations? I doubt it. I
certainly can't be sure, but common sense and experience suggest it is
unlikely. However, I don't have anything like a statistical basis for
claiming one way or the other.

(Maybe there are other issues that would cause programs to fail with
64-bit int.)

> But what evidence exactly do you want?
>

A link to a study or report saying "We took 1000 C programs and tried
compiling them with 64-bit int - over 50% had serious problems" would be
nice. Something other than pure gut feeling from one person.

(I haven't any doubt that /some/ programs would fail with 64-bit int.
It's the claim of more than half that is the problem.)

> Either there is going to be a big problem, or there isn't, but suppose
> you need to decide whether you're going to make 'int' 64 bits. What
> would /you/ do?
>

Clearly it's too late for existing C implementations or platforms (other
than old Cray's), so are you talking about a hypothetical new one for a
new platform with an ABI that has 64-bit int? It is, after all, the
platform ABI that determines the size of "int" - C compilers do not have
a free choice if they want to be useful.

> Do /you/ think there will be many problems with programs breaking,
> because there is either a deliberate or inadvertent reliance on int
> being 32 bits?
>

I think a lot more would break because they assume "int" is at least
32b-bit, than would break because they assume "int" is at most 32-bit or
exactly 32-bit.

> 'int' is probably the most-used C type in C code.
>
> Time to put your money on this again! Or will you just go for it
> because, after all, there is no real evidence that anything will go wrong?
>

I am not a betting man. But if I were, I would bet good money that you
would never be able to gather real evidence to your claim within a
period of, say, 5 years.

I am sure you would have no problem finding a range of examples where
64-bit int would cause trouble. But that would not prove your claim, or
even count as supporting evidence for it.

> Note that MS probably left 'long' as 32 bits, when 'int' became 32 bits
> too, for similar reasons.
>

You haven't given any reasons as to why 64-bit int could be a problem.
I gave one myself, further up - if you have others, feel free to add the
main ones.

Remember, MS could well have left "long" as 32-bit for efficiency
reasons - that would not count.

> (I suspect I'm the only one here who has attempted to make a C with a
> 64-bit int, to try it out. It didn't work, but there were many other
> reasons for that.
>
> That the C library still used 32 bits, even if I changed the APIs to
> ensure that was 'int' was the 32-bit equivalent, may have been one
> factor why the experiment wouldn't work unless I also recompiled the
> library from source using 64-bit int.)
>

You can't make "int" 32-bit in the compiler alone - it has to be part of
the ABI. That means it would be the size used in any API's on the
platform. (System libraries also count as "programs" that would need to
be recompiled with 64-bit int.)

> > I think most C programmers have come across variants and alternatives to
> > "int32_t" that have much the same meaning.  But these alternatives
> > typically come from either:
> >
> > 1. Code with a history from before C99 and the <stdint.h> types.
> > 2. Code written to work with pre-C99 toolchains.
> > 3. Newer code referring to or using type 1 or 2 code.
> > 4. Code that uses different names to distinguish types for different
> > purposes, perhaps using more advanced linters to check usage in a
> > stronger manner than C compilers typically support.
>
> You're not going to be convinced are you, no matter how many examples I
> might come up with!
>

I am reasonably sure - from common sense and experience - that what I
gave above are the main reasons for programmers to use some kind of
equivalent to "int32_t" with a different name but the same meaning. I
don't see any examples that you have listed that do not fit at least one
of these categories.

> There must always be /some other/ reason why somebody defines a new
> alias on top of `int32_t`, because there's hardly going to be a comment
> that says it's because they are ugly or long-winded.

Yes, I think that is usually the case. I don't suggest that everyone
thinks "int32_t" is particularly "pretty", but I do think that few
people care enough to use a different name solely because they find it
ugly or want to save a couple of keypresses. I have seen no
justification that anyone other than /you/ thinks this way.

>
> BTW here's an extract from a Raylib module:
>
>   unsigned int defaultFontData[512] = {
>         0x00000000, 0x00000000, 0x00000000, 0x00000000,
>         0x00200020, 0x0001b000, 0x00000000, 0x00000000,
>         0x8ef92520, 0x00020a00, 0x7dbe8000, 0x1f7df45f,
>
> I guess 'int' had better be 32 bits in this case!
>

Yes, I guess so. But what do you think that proves?

If the file had started with:

#include <stdint.h>

// uint32_t is just so horribly ugly and long-winded
// that I can't bear to use it in my coding
typedef uint32_t uint32;

and then later written:

uint32 defaultFontData[512] = ...

then I would accept that you are not alone in your opinions. But that's
not what your example shows - it merely shows the well-known fact that a
lot of code assumes "int" is at least 32-bit. (It does not show that it
assumes "int" is /exactly/ 32-bit.)

>
>
> > I have only ever heard of one person who actively chooses some variant
> > other than the <stdint.h> types such as int32_t from a free choice,
> > without any particular reason or justification other than that they
> > think the identifier "int32_t" is ugly.  You can guess who that
> person is.
>
> If you're generating C code, then those also take up more space for no
> reason. There I will use short forms like 'i32'.
>

That would be saving space for no reason. But we already know you have
unusual ideas about what is important to you in your generated code, and
things like portability and use of standard types means nothing to you.

> (Actually, my generated C code doesn't use any standard headers, so that
> `int32_t` doesn't exist, and the standard header would anyway only
> define it on top of `int`.)
>
>

Re: you think rust may outthrone c?

<47ae2689-2012-43a3-a0ab-db755a57a7b4n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ac8:7f48:0:b0:403:e8a7:bd9b with SMTP id g8-20020ac87f48000000b00403e8a7bd9bmr1582qtk.11.1690469608772;
Thu, 27 Jul 2023 07:53:28 -0700 (PDT)
X-Received: by 2002:a05:6808:16a7:b0:3a1:ce2a:4ca5 with SMTP id
bb39-20020a05680816a700b003a1ce2a4ca5mr6213174oib.6.1690469607334; Thu, 27
Jul 2023 07:53:27 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 27 Jul 2023 07:53:26 -0700 (PDT)
In-Reply-To: <u9tu9f$1t5jb$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=81.143.231.9; posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 81.143.231.9
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com> <u9tqj6$1sr5t$1@dont-email.me>
<6783b3a8-b11f-4159-a4d2-165fd2bf8c01n@googlegroups.com> <u9tu9f$1t5jb$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <47ae2689-2012-43a3-a0ab-db755a57a7b4n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 27 Jul 2023 14:53:28 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3851
 by: Malcolm McLean - Thu, 27 Jul 2023 14:53 UTC

On Thursday, 27 July 2023 at 15:17:33 UTC+1, David Brown wrote:
> On 27/07/2023 15:31, Malcolm McLean wrote:
>
> > But you haven't answered the question, which is a victory for Bart. There
> > is no type we can use for mysterytype_t which is really satisfactory.
> >
> If you wanted an artificial question to provoke an answer of "there is
> no good answer", why not just ask for a C type that is guaranteed to
> have more than 64 bits?
>
> My answer to your question was, I think, a lot more informative - it
> showed that in realistic situations when there is apparently a problem
> picking a type, it is more likely that there is a problem with the code
> or algorithm, or at least better ways to formulate it.
>
You can always code round problems. So if you are banned from using
signed types, there are ways and means of writing code so that you can
still obtain correct answer, even if the straightforwards thing to do would
be to generate a negative integer. But there's basically nothing wrong
with the filter code. It's not terribly efficient, but in a lot of contexts,
that doesn't matter, and it's far preferable to have simple code which
can be easily checked, and written very quickly, rather than a complicated
solution.
>
> However, if you were to simply ask "what type should you use in C for 65
> bits signed", there is no suitable type in standard C. You could use
> common 64-bit compiler extensions such as __int128 or similar names, or
> you would have to build one manually from two 64-bit integer types. But
> this is nothing new or surprising to anyone.
>
It's quite likely that size_t is 64 bits. If size_t is 32 bits, it's just possible that
the sample size plus the filter size overflows a size_t (it would have to be
an odd architecture with non-flat memory spaces). If we make index an
int64_t then we are safe. But it's slow. However you can argue that since
the function is slower than it needs to be anyway, a bit of a further slowdown
won't hurt.

Re: you think rust may outthrone c?

<u9u10h$1te0v$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 16:03:45 +0100
Organization: A noiseless patient Spider
Lines: 49
Message-ID: <u9u10h$1te0v$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<ESuwM.246845$GMN3.106013@fx16.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 15:03:45 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f6c6f94519e1a2521af762b44f8b9876";
logging-data="2013215"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18DISr3YruXHW6BDbEEbG9WRwJzWecN4Ew="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:YmFTE7g0nTe+0WNx9AaI4sLDbJU=
In-Reply-To: <ESuwM.246845$GMN3.106013@fx16.iad>
 by: Bart - Thu, 27 Jul 2023 15:03 UTC

On 27/07/2023 15:07, Scott Lurndal wrote:
> David Brown <david.brown@hesbynett.no> writes:
>> On 26/07/2023 23:07, Bart wrote:
>
>>> >> * 64-bit ints would kick the signed overflow can much further
down the
>>
>> (I actually agree that there would have been many advantages to making
>> "int" 64-bit on 64-bit systems. But there would also have been a key
>> disadvantage - it would make it very inconvenient to get 16-bit and
>> 32-bit types with standard C integer types.)
>
> The concerns at the time revolved around the additional memory
> required to make all 'int' (and enum, etc) 64-bit.

An enum name is just a named constant. It doesn't take up any more space
than is needed.

If you mean the space needed when used as a variable's type like this:

enum {x, y, z} c[1000];

where `c` occupies 4000 bytes, then you can equally say that it wastes
2000 or 3000 bytes given that you only need a byte to represent the
values of x, y, z.

Is there no way of overriding the type in C? (Other than just using an
8- or 16-bit type anyway as I do.)

Otherwise there is no real issue with space, not for standalone
variables. Bear in that registers and stacks will be 64 bits anyway.

For the most efficient arrays and structs, people can use narrower ints
as needed, even for individual variables if worried about a few extra bytes.

The only problem I've found is specific to x64, since 64-bit versions of
many instruction encodings often need an extra byte compared to the
32-bit version (due to needing the W-bit set in the REX prefix).

But even here, the language could be designed so that 32-bit operands of
a binary op are not automatically promoted to the full 64 bits.

However that is not how C works, and not how mine works now (versions of
it for Z80 for example, which came up in another thread, did not promote
8-bit operands to 16-bits).

Re: you think rust may outthrone c?

<u9u5cd$1tqc9$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 17:18:21 +0100
Organization: A noiseless patient Spider
Lines: 156
Message-ID: <u9u5cd$1tqc9$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <u9u040$1tbdh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 16:18:21 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f6c6f94519e1a2521af762b44f8b9876";
logging-data="2025865"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zSB4QRK5uD7Z9r9C+wNX/oIXNNYLSy1U="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:aF3VdbjpPaIwkuI4X/wrQWQsg/E=
In-Reply-To: <u9u040$1tbdh$1@dont-email.me>
 by: Bart - Thu, 27 Jul 2023 16:18 UTC

On 27/07/2023 15:48, David Brown wrote:
> On 27/07/2023 15:30, Bart wrote:
>>
>> Note that MS probably left 'long' as 32 bits, when 'int' became 32
>> bits too, for similar reasons.
>>
>
> You haven't given any reasons as to why 64-bit int could be a problem. I
> gave one myself, further up - if you have others, feel free to add the
> main ones.

It either won't work, or will result in programs that are not as
efficient as expected, because that tightly crafted struct now takes up
16 bytes rather than 8 (and on Win64 is passed by reference rather than
by value):

struct {
int a;
char b,c,e,f;
} S;

> You can't make "int" 32-bit in the compiler alone - it has to be part of
> the ABI.

The ABI is nothing to do with it. 'int' is a label used in many
programming languages where it has a meaning specific to those languages.

The main Win64 ABI reference doesn't assign type names to the
1-2-4-8-byte sizes that are passed in GP registers, but where it does,
then C's 'int' is a minor part of it:

https://learn.microsoft.com/en-us/cpp/build/x64-software-conventions?view=msvc-170

Because, when you think about it, when language A wants to call language
B via an FFI, C doesn't come into it at all. Neither A nor B might even
have a type called 'int'.

The compilers of both A and B need to know where to put objects of a
certain size when making function calls using the FFI.

>> You're not going to be convinced are you, no matter how many examples
>> I might come up with!
>>
>
> I am reasonably sure - from common sense and experience - that what I
> gave above are the main reasons for programmers to use some kind of
> equivalent to "int32_t" with a different name but the same meaning. I
> don't see any examples that you have listed that do not fit at least one
> of these categories.
>
>> There must always be /some other/ reason why somebody defines a new
>> alias on top of `int32_t`, because there's hardly going to be a
>> comment that says it's because they are ugly or long-winded.
>
> Yes, I think that is usually the case. I don't suggest that everyone
> thinks "int32_t" is particularly "pretty", but I do think that few
> people care enough to use a different name solely because they find it
> ugly or want to save a couple of keypresses. I have seen no
> justification that anyone other than /you/ thinks this way.

I have seen plenty of open source examples that precisely use typedefs
to define i32 etc on top of the stdint.h types. Or maybe they're Rust or
Zig programmers forced to write some C, and want to feel at home.

But I'm not going to spend days trawling through 1000s of sites I've
visited to try and find those examples.

See, however, pages like this:

https://stackoverflow.com/questions/3340843/why-do-c-programmers-use-typedefs-to-rename-basic-types

Or this:

https://stackoverflow.com/questions/30896489/why-is-u8-u16-u32-u64-used-instead-of-unsigned-int-in-kernel-programming

This one might help explain why C99 went with uint32_t instead of u32,
but you will at least think about why they used such a short type name
in that software, and not have have few letters, some underscores, and a
pointless suffix that you see in NO other langauges.

As I said, you will not be convinced, or will say it's a one-off. (Why
won't you be convinced? Is it that inconceivable that someone might
prefer a snappier, possibly more euphonious set of types for their coding?)

>> BTW here's an extract from a Raylib module:
>>
>> unsigned int defaultFontData[512] = {
>> 0x00000000, 0x00000000, 0x00000000, 0x00000000,
>> 0x00200020, 0x0001b000, 0x00000000, 0x00000000,
>> 0x8ef92520, 0x00020a00, 0x7dbe8000, 0x1f7df45f,
>>
>> I guess 'int' had better be 32 bits in this case!
>>
>
> Yes, I guess so. But what do you think that proves?

This is the conversation from a week ago where people had a go at me for
assuming int = 32 bits, but EVERYONE does it in the real word.

BTW, if `int` was to changed to 64 bits, this table would be double the
size needed.

>> If you're generating C code, then those also take up more space for no
>> reason. There I will use short forms like 'i32'.
>>
>
> That would be saving space for no reason.

Fine, I'll start using `unsigned long long int` then instead of `u64`!
It takes 1% longer to generate, takes 1% more disk space, and takes 1%
bit longer longer to parse, but that's OK.

BTW 1% is also the UK's contribution to global warming, where it is
considered a big deal.

In my generated code, casts involving these types are used VERY
extensively. For example, every `0` constant is written as `(i64)0`.

> But we already know you have
> unusual ideas about what is important to you in your generated code, and
> things like portability

I'm the one who used to test generated code across across 6 compilers,
remember, and that was just the Windows versions.

> and use of standard types means nothing to you.

It's generated code, who cares?! The file starts off like this, using
STANDARD TYPES:

typedef signed char i8;
typedef short i16;
typedef int i32;
typedef long long i64;

typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
typedef unsigned long long u64;

typedef unsigned char byte;

typedef float r32;
typedef double r64;

I do have to inspect the code from time to type when things go wrong,
and these forms suit me.

Have you never used a typedef to create an alias for a numeric type? If
not, then what on earth is typedef for? It can't be solely for
simplifying complicated type specs.

Re: you think rust may outthrone c?

<cda065bd-58b5-466d-b91e-d885d9966815n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:ae9:df42:0:b0:767:2891:eb97 with SMTP id t63-20020ae9df42000000b007672891eb97mr2588qkf.6.1690476340472;
Thu, 27 Jul 2023 09:45:40 -0700 (PDT)
X-Received: by 2002:a05:6870:3a2a:b0:1bb:73c2:9ad0 with SMTP id
du42-20020a0568703a2a00b001bb73c29ad0mr4148819oab.3.1690476339440; Thu, 27
Jul 2023 09:45:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 27 Jul 2023 09:45:39 -0700 (PDT)
In-Reply-To: <u9u5cd$1tqc9$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:dd30:b3b3:c3fe:88aa;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:dd30:b3b3:c3fe:88aa
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <u9u040$1tbdh$1@dont-email.me> <u9u5cd$1tqc9$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <cda065bd-58b5-466d-b91e-d885d9966815n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Thu, 27 Jul 2023 16:45:40 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 3043
 by: Malcolm McLean - Thu, 27 Jul 2023 16:45 UTC

On Thursday, 27 July 2023 at 17:18:36 UTC+1, Bart wrote:
>
> It's generated code, who cares?! The file starts off like this, using
> STANDARD TYPES:
>
> typedef signed char i8;
> typedef short i16;
> typedef int i32;
> typedef long long i64;
>
> typedef unsigned char u8;
> typedef unsigned short u16;
> typedef unsigned int u32;
> typedef unsigned long long u64;
>
> typedef unsigned char byte;
>
> typedef float r32;
> typedef double r64;
>
> I do have to inspect the code from time to type when things go wrong,
> and these forms suit me.
>
> Have you never used a typedef to create an alias for a numeric type? If
> not, then what on earth is typedef for? It can't be solely for
> simplifying complicated type specs.
>
I'm very unwilling to do this.
If we say typedef double real; is that meant to mean that the code should still
work if we replace double with float? Is this tested? Or does it mean that for
some reason we must have 64 bit floating point numbers? Or is it just that
someone thinks that "real" is a more informative nane for a type than "double"?

Then what is the scope of this symbol. What business has a graphics library, for example,
in exporting an identifier like "real"?

Re: you think rust may outthrone c?

<20230727103045.970@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 17:36:51 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 12
Message-ID: <20230727103045.970@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com> <u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
<871qgujuhv.fsf@bsb.me.uk>
<c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com>
<87h6pqot5q.fsf@nosuchdomain.example.com>
<38a28d33-3a89-4905-b3f3-94ad7e27bd03n@googlegroups.com>
Injection-Date: Thu, 27 Jul 2023 17:36:51 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="8b46a856f685959d89dbb9806175f5b3";
logging-data="2044112"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180aIVbDDdAylQveydHAl9R5hVnQN6KG98="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:v6sj9rVf/e2HEmmD2k/QrAvRV8M=
 by: Kaz Kylheku - Thu, 27 Jul 2023 17:36 UTC

On 2023-07-27, Malcolm McLean <malcolm.arthur.mclean@gmail.com> wrote:
> You can argue that char *str = "123" is not a string of letters because digits
> are not letters, and if you were using the term normally then that's what you
> might mean. But I'm using "of letters" as a drop-in for "literal", to show you
> that that's what it means. "Litera", Latin "letter" so "literal", "of letters".

JulyTheTwentySeventhTwentyTwentyThreeFromManOfLettersToMalcolmMacLeanDearMalcolmCouldYouExplainTheJokeInYourPreviousLetterItWentOverMyHead

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: you think rust may outthrone c?

<u9uceh$1ulb7$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 19:18:57 +0100
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <u9uceh$1ulb7$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <u9u040$1tbdh$1@dont-email.me>
<u9u5cd$1tqc9$1@dont-email.me>
<cda065bd-58b5-466d-b91e-d885d9966815n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 27 Jul 2023 18:18:58 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="f6c6f94519e1a2521af762b44f8b9876";
logging-data="2053479"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/599ngKRMRQOZ7Ps1kcUrADadGfKgBQL8="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:xT+4DYszTHNBmHwAGQ8xZD9PmIE=
In-Reply-To: <cda065bd-58b5-466d-b91e-d885d9966815n@googlegroups.com>
 by: Bart - Thu, 27 Jul 2023 18:18 UTC

On 27/07/2023 17:45, Malcolm McLean wrote:
> On Thursday, 27 July 2023 at 17:18:36 UTC+1, Bart wrote:
>>
>> It's generated code, who cares?! The file starts off like this, using
>> STANDARD TYPES:
>>
>> typedef signed char i8;
>> typedef short i16;
>> typedef int i32;
>> typedef long long i64;
>>
>> typedef unsigned char u8;
>> typedef unsigned short u16;
>> typedef unsigned int u32;
>> typedef unsigned long long u64;
>>
>> typedef unsigned char byte;
>>
>> typedef float r32;
>> typedef double r64;
>>
>> I do have to inspect the code from time to type when things go wrong,
>> and these forms suit me.
>>
>> Have you never used a typedef to create an alias for a numeric type? If
>> not, then what on earth is typedef for? It can't be solely for
>> simplifying complicated type specs.
>>
> I'm very unwilling to do this.
> If we say typedef double real; is that meant to mean that the code
should still
> work if we replace double with float?

What if you replaced double with float anyway; what has that got to do
with that typedef?

Note that the example above comes from generated code; the scope is
purely the extent of that source file.

However, if I see these types in an API (presumably with some matching
typedefs nearby), I wouldn't have a problem with them at all.

> Is this tested? Or does it mean that for
> some reason we must have 64 bit floating point numbers? Or is it just
that
> someone thinks that "real" is a more informative nane for a type than
"double"?

Is it for other people's use or your own? I wouldn't use 'real' in an
API I expect other people to use; I'd use something like f64 or float32.

But what on earth are `float` and `double` anyway? They are /probably/
f32 and f64, but I'm sure the C standard does not define them as clearly
as that!

> Then what is the scope of this symbol. What business has a graphics
library, for example,
> in exporting an identifier like "real"?

I gave an example last week where each of OpenGL, GTK an SDL used their
own typedefs for integer types. 'real' would be too obscure for that
purpose.

Re: you think rust may outthrone c?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 20:03:30 +0100
Organization: A noiseless patient Spider
Lines: 65
Message-ID: <87edktgosd.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<u9edc7$3bdu0$1@dont-email.me> <u9em5t$3d7sv$1@dont-email.me>
<875y6dne2u.fsf@nosuchdomain.example.com>
<u9evak$3eutv$1@dont-email.me>
<3ff53ffd-299b-4dc8-a503-cfd170ce3e03n@googlegroups.com>
<u9gbnu$3pc9g$1@dont-email.me> <u9h29k$3ssnr$1@dont-email.me>
<u9hob6$3vo3c$1@dont-email.me> <u9jig1$9lnb$2@dont-email.me>
<u9jm4i$a4dp$1@dont-email.me> <u9jqnf$ak1k$1@dont-email.me>
<u9juf1$avv8$1@dont-email.me> <u9lafa$j89a$1@dont-email.me>
<u9li0r$k6vn$1@dont-email.me> <87ila9laoa.fsf@bsb.me.uk>
<86cz0fs86n.fsf@linuxsc.com> <87pm4fqppe.fsf@nosuchdomain.example.com>
<ec9e4fb6-0241-42c3-b037-437d98f06787n@googlegroups.com>
<871qgujuhv.fsf@bsb.me.uk>
<c3d85960-93a1-4269-a024-46a4fd38d0d4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5a5e343133fc3f20981bd9b482679604";
logging-data="2056646"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+KGFZBO7mF3sCigicJ6Ro5XEL1ycPpMbo="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:MhAXg7zXsX80AJTF9mZWgK4WE0M=
sha1:+IIB8XKx6enMXs6Hg5Ak0hh3IKM=
X-BSB-Auth: 1.18e9358ec17ff81a31c6.20230727200330BST.87edktgosd.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 27 Jul 2023 19:03 UTC

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

> On Wednesday, 26 July 2023 at 21:19:55 UTC+1, Ben Bacarisse wrote:
>> Malcolm McLean <malcolm.ar...@gmail.com> writes:
>>
>> > On Wednesday, 26 July 2023 at 05:09:22 UTC+1, Keith Thompson wrote:
>> >> Tim Rentsch <tr.1...@z991.linuxsc.com> writes:
>> >> > Ben Bacarisse <ben.u...@bsb.me.uk> writes:
>> >> [...]
>> >> >> Yes, C++ calls them literals. But that site does use the same
>> >> >> terminology as the C standard when talking about C:
>> >> >>
>> >> >> https://en.cppreference.com/w/c/language/integer_constant
>> >> >>
>> >> >> I prefer C++'s usage, since "integer constant" can be so easily
>> >> >> confused for "integer constant expression".
>> >> >
>> >> > Using the same term for both suggests a false equivalence, and
>> >> > also is ahistorical. The two kinds of entities are fundamentally
>> >> > different: constants denote values, literals denote objects.
>> >> > Constants, like mathematical constants, always denote the same
>> >> > value; literals denote different objects at different times or
>> >> > places, even if the values used to produce a given literal are
>> >> > always the same, which they need not be. The distinctions are
>> >> > too important to gloss over by using a common term for both.
>> >> When you say that "literals denote objects", are you referring
>> >> specifically to the way C uses the terms "string literal" and "compound
>> >> literal"?
>> >>
>> >> I haven't done an exhaustive search, but every language other than C
>> >> whose documentation I've just checked (C++, Ada, Perl, Python, Go, Java)
>> >> calls 42 an integer literal and "foo" a string literal. C is a bit of
>> >> an outlier in callling 42 an integer constant.
>> >>
>> >> I suggest that the fact that C uses "constant" for tokens that refer to
>> >> values and "literal" (string or compound) for constructs that refer to
>> >> anonymous objects was an arbitrary choice, and the distinction you
>> >> mention is not nearly as fundamental as you suggest it is.
>> >>
>> >> I do prefer to use the term "integer constant" when discussing C, but
>> >> the phrase "integer literal" is (a) correct in most other languages and
>> >> (b) perfectly clear. It wouldn't occur to me that "integer literal"
>> >> implies something that refers to an object.
>> >>
>> > The word "literal" means "of letters". So in this case C has it right, the
>> > other languages have it wrong.
>> If you are going be so literal, you need to explain how "" (in C) is "of
>> letters". And, since you presumably consider "123" to be "of letters",
>> why calling 123 an "integer literal" would be wrong. Anyway, technical
>> uses of words like literal are almost always figurative!
>>
> C source is human-readable. So in a sense, everything in the source
> code is "literal". So in the statement int x = 123; we can say that
> "123" is a "literal" if we want. But only if we also accept that
> "int", "x" and "=" are also "literals".

What a silly thing to say. We are entitled to use words in helpful
ways. We are not forced by naive etymology to give up a useful term
that is widely accepted and has a long history. I will continue to
refer to things like 123 as literals (though I do try to avoid that
usage when talking about C) without feeling any obligation follow your
notion of what we must accept.

--
Ben.

Re: you think rust may outthrone c?

<878rb1gmur.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 20:45:16 +0100
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <878rb1gmur.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<b803f348-3a56-42cc-93eb-ccb16b961e8fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="5a5e343133fc3f20981bd9b482679604";
logging-data="2071527"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18QDnVJeypBexmZz0AdUeXmgGHKKlJIUjY="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:1jfBdWW5Q6K3YWXBq8aC2+Aiczo=
sha1:c3A9aXYaxXwEcpn8RLnQzUYKcbk=
X-BSB-Auth: 1.f04bf2d6709a18a5d29a.20230727204516BST.878rb1gmur.fsf@bsb.me.uk
 by: Ben Bacarisse - Thu, 27 Jul 2023 19:45 UTC

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

> Take this code

Is this obviously not real code. That does not normally matter, but I
think you've ended up with something that can't illustrate the problem
you have in mind.

> void filter(float *out, const float *in, size_t N, const float *filter, size_t Nf)
> {
> mysterytype_t index;
> size_t i, j;
>
> for ( i =0; i < N; i=i++)

The assignment to i is UB. Looks like a typo for either i=i+1 or i++.

> {
> out[i] = 0.0f;
> for(j = 0, index = i - Nf/2; j < Nf; j++, index++)
> {
> if (index < 0 || index >= N)

Here, it looks like index is supposed to be a signed type, but it gets
assigned a value with (probable) unsigned type (i - Nf/2) and is only
ever incremented.

> contiue;

typo

> out[index] += in[i] * filter[j];
> }
> }
> }
>
> What would you use for mysterytype_t?

As the code stands (with the typos corrected) an unsigned type like
size_t would work, but I don't think that's what you were asking.
Something is wrong in the rest of the code.

--
Ben.

Re: you think rust may outthrone c?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Thu, 27 Jul 2023 13:13:52 -0700
Organization: None to speak of
Lines: 59
Message-ID: <87zg3hnmdb.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="f8957b03f6dc45951cee385c25f0e511";
logging-data="2076763"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18hu1i64tTHtf4ogMIpwuAa"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:rZ+qwjx+Uz8IvQLOTAFFLBK5G7o=
sha1:GWkjxrppmFl1Q3WexgtwsCGxANs=
 by: Keith Thompson - Thu, 27 Jul 2023 20:13 UTC

Bart <bc@freeuk.com> writes:
[...]
> (I suspect I'm the only one here who has attempted to make a C with a
> 64-bit int, to try it out. It didn't work, but there were many other
> reasons for that.

I've worked on implementations with 64-bit int. One such system had
8-bit char and 64-bit short, int, and long. Another had 8-bit char,
32-bit short, and 64-bit int and long. I worked with C and C++ code
running under a Unix-based OS, though I was not a direct author of
maintainer of that code. I don't recall any problems due to int being
wider than 32 bits. There may well have been some problems that I
wasn't aware of. (The systems were Cray vector computers.)

As you know, making int 64 bits is a choice of an implementation, not a
change to the language. Making char 8 bits and int 64 bits means that
you can't have predefined 16-bit and 32-bit integer types (short can be
one or the other, or neither). That, I speculate, is part of the reason
modern 64-bit systems tend to have 32-bit int.

> That the C library still used 32 bits, even if I changed the APIs to
> ensure that was 'int' was the 32-bit equivalent, may have been one
> factor why the experiment wouldn't work unless I also recompiled the
> library from source using 64-bit int.)

If you change int to 64 bits for user code and leave it as 32 bits in
the API and standard library, *of course* you're going to break things.

(It would be interesting to have, say, a Linux x86_64 distribution with
64-bit int. CHAR_BIT > 8 would also be interesting, but that would
violate POSIX.)

[...]

> BTW here's an extract from a Raylib module:
>
> unsigned int defaultFontData[512] = {
> 0x00000000, 0x00000000, 0x00000000, 0x00000000,
> 0x00200020, 0x0001b000, 0x00000000, 0x00000000,
> 0x8ef92520, 0x00020a00, 0x7dbe8000, 0x1f7df45f,
>
> I guess 'int' had better be 32 bits in this case!

Certainly int would have to be *at least* 32 bits wide for that
declaration to be valid. Taking a look at the source code (see, for
example, src/rcore.c lines 201-210), it requires either _WIN32 or POSIX,
which guarantees that int is at least 32 bits.

I haven't studied the code closely enough to know whether it would work
with a 64-bit int.

Have you?

[...]

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

Re: you think rust may outthrone c?

<873518hkp6.fsf@bsb.me.uk>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: ben.use...@bsb.me.uk (Ben Bacarisse)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Fri, 28 Jul 2023 02:46:29 +0100
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <873518hkp6.fsf@bsb.me.uk>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<87o7k8rzh5.fsf@nosuchdomain.example.com>
<0fa83b40-26e6-427a-ba84-6cf8ac33172an@googlegroups.com>
<u98odb$25mj8$1@dont-email.me>
<87jzuvsg7q.fsf@nosuchdomain.example.com>
<u9cfmj$2trto$1@dont-email.me>
<87h6pyqgnp.fsf@nosuchdomain.example.com>
<u9cld3$2uof8$1@dont-email.me>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <u9jgmu$9i98$1@dont-email.me>
<87o7k2l4ge.fsf@bsb.me.uk> <u9m5rp$nbif$1@dont-email.me>
<87o7k0kbq5.fsf@bsb.me.uk> <u9o1ie$12n8g$1@dont-email.me>
<87cz0gj8wl.fsf@bsb.me.uk> <u9p5rq$16jij$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="b8f7e324aecb05e9b3b48a4ce3159635";
logging-data="2138163"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rdWPqEPvr0ys90UFZWF3FE3dB8WUm3vs="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:qCLwr8iK2oNnWyatnph5kyJHSlk=
sha1:t8gWgEOPOF6xQldxxwtoosUEOLk=
X-BSB-Auth: 1.74aeb7b3598de4d3031c.20230728024629BST.873518hkp6.fsf@bsb.me.uk
 by: Ben Bacarisse - Fri, 28 Jul 2023 01:46 UTC

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

> (Lack of time means I am afraid I must cut this short, and I don't expect
> to post again for a couple of weeks. It has been an enjoyable discussion.
> Next time I will try to arm myself with references and examples first, and
> then express myself a bit better!)

I'm going to wrap this up too. I always find it interesting when
there's a disagreement about stuff like this, but although I could say
more, I don't think there much more to be gained.

--
Ben.

Re: you think rust may outthrone c?

<ua1fqr$2bksk$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Fri, 28 Jul 2023 23:35:08 +0100
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <ua1fqr$2bksk$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <87zg3hnmdb.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 28 Jul 2023 22:35:07 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4499a152026011cd009e4bb37a25d4eb";
logging-data="2478996"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18vSKQu0x+61GIu1IaWXAkMyh75EMSWplo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:wBIpR6ttVKef+mOdINr8qNHmoFk=
In-Reply-To: <87zg3hnmdb.fsf@nosuchdomain.example.com>
 by: Bart - Fri, 28 Jul 2023 22:35 UTC

On 27/07/2023 21:13, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
> [...]
>> (I suspect I'm the only one here who has attempted to make a C with a
>> 64-bit int, to try it out. It didn't work, but there were many other
>> reasons for that.
>
> I've worked on implementations with 64-bit int. One such system had
> 8-bit char and 64-bit short, int, and long. Another had 8-bit char,
> 32-bit short, and 64-bit int and long. I worked with C and C++ code
> running under a Unix-based OS, though I was not a direct author of
> maintainer of that code. I don't recall any problems due to int being
> wider than 32 bits. There may well have been some problems that I
> wasn't aware of. (The systems were Cray vector computers.)

I was thinking of a more contemporary scenario, one where there are
billions of lines of existing code that may have assume a certain 'int'
size that would be put to the test.

A large proportion of which would not have been written by the sort of
exacting programmers who would have been allowed near 1970s supercomputers.

> As you know, making int 64 bits is a choice of an implementation, not a
> change to the language. Making char 8 bits and int 64 bits means that
> you can't have predefined 16-bit and 32-bit integer types (short can be
> one or the other, or neither). That, I speculate, is part of the reason
> modern 64-bit systems tend to have 32-bit int.

So you only have 'short' to select between 16-bit and 32-bit ints? I
admit that can be a bit of quandry, but surely it is a ridiculous reason
to deny language users a proper 64-bit type!

>> BTW here's an extract from a Raylib module:
>>
>> unsigned int defaultFontData[512] = {
>> 0x00000000, 0x00000000, 0x00000000, 0x00000000,
>> 0x00200020, 0x0001b000, 0x00000000, 0x00000000,
>> 0x8ef92520, 0x00020a00, 0x7dbe8000, 0x1f7df45f,
>>
>> I guess 'int' had better be 32 bits in this case!
>
> Certainly int would have to be *at least* 32 bits wide for that
> declaration to be valid. Taking a look at the source code (see, for
> example, src/rcore.c lines 201-210), it requires either _WIN32 or POSIX,
> which guarantees that int is at least 32 bits.
>
> I haven't studied the code closely enough to know whether it would work
> with a 64-bit int.

My interest in it is purely due to being routinely castigated for
assuming that 'int' these days is typically 32 bits in size for most
developers.

But presumably such an assumption is OK when everyone else does it.

So does POSIX not work on any 16-bit UNIX systems where 'int' might be
16 bits?

My assertion is that most involved with software development are using
the kinds of machines that Raylib runs on, and those using C will likely
be using a 32-bit 'int'.

It makes sense then to assume that in discussions, and to only bring up
the pedantic fact that the C standard, which has to cater for obsolete
and unusual systems, defines only a minimum 16-bit size, when it's
relevant. And not use that to browbeat people with.

But it is also those very assumptions which lead me to /speculate/ that
suddenly making 'int' and '123' be 64 bits overnight would not end well.

> Have you?

I have used 64-bit ints in my everyday language for a decade. So I am
sensitive to the exact types used within arrays and structs since just
blindly using `int` could easily make them inefficient, since it means 4
extra bytes on top of 2-3 extra when 32-bit int is already overkill.

But to answer your question, no I haven't looked at it. However I /have/
worked extensively decades ago with just such bitmapped character glyph
data, and having the wrong stride between elements could easily cause
significant problems.

Re: you think rust may outthrone c?

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

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Fri, 28 Jul 2023 19:21:33 -0700
Organization: None to speak of
Lines: 83
Message-ID: <87h6pno3te.fsf@nosuchdomain.example.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com>
<u9dm6t$370v3$1@dont-email.me> <u9dv2c$38ir2$1@dont-email.me>
<u9e7bp$3a1ug$1@dont-email.me> <u9h055$3s62g$7@dont-email.me>
<87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me>
<87zg3hnmdb.fsf@nosuchdomain.example.com>
<ua1fqr$2bksk$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="d3b018c39647936c2599e5bfe2349293";
logging-data="2661854"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18U3j0iWdraI+Ni4cMa0EDI"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:EDpnsgR7f5WQUUW4kDm6F9J7Lm4=
sha1:a+Y/mss1fWFHQrb9p1ICmsHxOSE=
 by: Keith Thompson - Sat, 29 Jul 2023 02:21 UTC

Bart <bc@freeuk.com> writes:
> On 27/07/2023 21:13, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>> [...]
>>> (I suspect I'm the only one here who has attempted to make a C with a
>>> 64-bit int, to try it out. It didn't work, but there were many other
>>> reasons for that.
>>
>> I've worked on implementations with 64-bit int. One such system had
>> 8-bit char and 64-bit short, int, and long. Another had 8-bit char,
>> 32-bit short, and 64-bit int and long. I worked with C and C++ code
>> running under a Unix-based OS, though I was not a direct author of
>> maintainer of that code. I don't recall any problems due to int being
>> wider than 32 bits. There may well have been some problems that I
>> wasn't aware of. (The systems were Cray vector computers.)
>
> I was thinking of a more contemporary scenario, one where there are
> billions of lines of existing code that may have assume a certain
> 'int' size that would be put to the test.
>
> A large proportion of which would not have been written by the sort of
> exacting programmers who would have been allowed near 1970s
> supercomputers.

The systems in question ran Unicos, Cray's version of Unix. The system
included the usual Unix software. Presumably programmers working for
Cray would have ported it to those systems; the original authors likely
didn't have access to such systems. I have no idea how much effort was
required to port it. Much of it might have just had to be recompiled.

>> As you know, making int 64 bits is a choice of an implementation, not a
>> change to the language. Making char 8 bits and int 64 bits means that
>> you can't have predefined 16-bit and 32-bit integer types (short can be
>> one or the other, or neither). That, I speculate, is part of the reason
>> modern 64-bit systems tend to have 32-bit int.
>
> So you only have 'short' to select between 16-bit and 32-bit ints? I
> admit that can be a bit of quandry, but surely it is a ridiculous
> reason to deny language users a proper 64-bit type!

C has required support for at least 64-bit integers since C99. (Yes, I
know you're offended by the fact that int is not typically 64 bits.)

[...]

> My interest in it is purely due to being routinely castigated for
> assuming that 'int' these days is typically 32 bits in size for most
> developers.

I don't recall anyone castigating you for that. I believe you've been
criticized for saying, without qualification, that int is 32 bits, and
you react badly when anyone points out that the language doesn't
guarantee it.

In this thread, you've talked about changing int from 32 to 64 bits *as
if it were a change to the language*.

[...]

> So does POSIX not work on any 16-bit UNIX systems where 'int' might be
> 16 bits?

POSIX requires INT_MAX to be at least 2147483647 and INT_MIN to be at
most -2147483647. (I think that originated in Issue 5, 1997.) Any C
implementation that does not meet that requirement does not conform to
the current version of POSIX. I'm not aware of any current UNIX-like
systems with 16-bit int; there may be some for small embedded systems.

Perhaps what you're getting at is that the original PDP-11 UNIX would
not conform to POSIX?

> My assertion is that most involved with software development are using
> the kinds of machines that Raylib runs on, and those using C will
> likely be using a 32-bit 'int'.

Most. Not all.

[...]

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

Re: you think rust may outthrone c?

<b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:622a:1a24:b0:403:217c:568d with SMTP id f36-20020a05622a1a2400b00403217c568dmr14706qtb.12.1690614329112;
Sat, 29 Jul 2023 00:05:29 -0700 (PDT)
X-Received: by 2002:a9d:644a:0:b0:6b9:5156:a493 with SMTP id
m10-20020a9d644a000000b006b95156a493mr5440146otl.4.1690614328800; Sat, 29 Jul
2023 00:05:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Sat, 29 Jul 2023 00:05:28 -0700 (PDT)
In-Reply-To: <ua1fqr$2bksk$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:23a8:400a:5601:6c83:9fbc:2db2:919;
posting-account=Dz2zqgkAAADlK5MFu78bw3ab-BRFV4Qn
NNTP-Posting-Host: 2a00:23a8:400a:5601:6c83:9fbc:2db2:919
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk> <86tttts1g2.fsf@linuxsc.com>
<87351dm210.fsf@nosuchdomain.example.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <87zg3hnmdb.fsf@nosuchdomain.example.com> <ua1fqr$2bksk$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com>
Subject: Re: you think rust may outthrone c?
From: malcolm....@gmail.com (Malcolm McLean)
Injection-Date: Sat, 29 Jul 2023 07:05:29 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 5083
 by: Malcolm McLean - Sat, 29 Jul 2023 07:05 UTC

On Friday, 28 July 2023 at 23:35:23 UTC+1, Bart wrote:
> On 27/07/2023 21:13, Keith Thompson wrote:
> > Bart <b...@freeuk.com> writes:
> > [...]
> >> (I suspect I'm the only one here who has attempted to make a C with a
> >> 64-bit int, to try it out. It didn't work, but there were many other
> >> reasons for that.
> >
> > I've worked on implementations with 64-bit int. One such system had
> > 8-bit char and 64-bit short, int, and long. Another had 8-bit char,
> > 32-bit short, and 64-bit int and long. I worked with C and C++ code
> > running under a Unix-based OS, though I was not a direct author of
> > maintainer of that code. I don't recall any problems due to int being
> > wider than 32 bits. There may well have been some problems that I
> > wasn't aware of. (The systems were Cray vector computers.)
> I was thinking of a more contemporary scenario, one where there are
> billions of lines of existing code that may have assume a certain 'int'
> size that would be put to the test.
>
> A large proportion of which would not have been written by the sort of
> exacting programmers who would have been allowed near 1970s supercomputers.
> > As you know, making int 64 bits is a choice of an implementation, not a
> > change to the language. Making char 8 bits and int 64 bits means that
> > you can't have predefined 16-bit and 32-bit integer types (short can be
> > one or the other, or neither). That, I speculate, is part of the reason
> > modern 64-bit systems tend to have 32-bit int.
> So you only have 'short' to select between 16-bit and 32-bit ints? I
> admit that can be a bit of quandry, but surely it is a ridiculous reason
> to deny language users a proper 64-bit type!
>
You'd have to either make int32_t or similar a built in type, or you'd have to
invent an extension like "medium" . Otherwise with the rules as they are you
can have 16 bit or 32 bit shorts, but not both, and long has to be at least
as long as int.
int is the natural type to use for the number of children in a family.
int is the natural type to use for the number of employees in a company.
int is the natural type to use for the number of sound samples in an audio signal.

In the first case it is unlikely to go above ten and can't go above thirty.
In the second case it could go over 16 thousand but not over 2 billion.
In the third case it could go extremely high, but not above the capacity
of the machine to process the signal.

The first case is the most common type of data. Most integers in programs
are small. But normally iterating over children won't be. a performance
bottleneck. If we've got a 64 bit machine, we can afford the extra padding bytes.

The third case is more interesting. Iterating over audio samples could be enough
of a bottle neck that we need to use an efficient type. And a 44100 MHz stereo
sample will, break the 2 billion mark at about 8 hours. Unlikely you'd have a
sample that long, but not impossible (the movie Shoah is 9 hours 21 minutes).
However if you're going to slurp in the sundtrack to Shoah as one signal and
process it, you will certainly have a 64 bit machine. So the C system where int is
the "natural integer type to use on the machine" is ideal here.

Re: you think rust may outthrone c?

<ua2p3q$2ji83$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Sat, 29 Jul 2023 11:19:39 +0100
Organization: A noiseless patient Spider
Lines: 137
Message-ID: <ua2p3q$2ji83$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<878rbaqch6.fsf@nosuchdomain.example.com> <u9dm6t$370v3$1@dont-email.me>
<u9dv2c$38ir2$1@dont-email.me> <u9e7bp$3a1ug$1@dont-email.me>
<u9h055$3s62g$7@dont-email.me> <87351foebi.fsf@bsb.me.uk>
<86tttts1g2.fsf@linuxsc.com> <87351dm210.fsf@nosuchdomain.example.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <87zg3hnmdb.fsf@nosuchdomain.example.com>
<ua1fqr$2bksk$1@dont-email.me>
<b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jul 2023 10:19:38 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4499a152026011cd009e4bb37a25d4eb";
logging-data="2738435"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/sB1F321xCksB5iJIS+DKFPpyVI3kWPqo="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:sWRwPpBGSYWwHtawojoLK+KwPI0=
In-Reply-To: <b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com>
 by: Bart - Sat, 29 Jul 2023 10:19 UTC

On 29/07/2023 08:05, Malcolm McLean wrote:
> On Friday, 28 July 2023 at 23:35:23 UTC+1, Bart wrote:
>> On 27/07/2023 21:13, Keith Thompson wrote:
>>> Bart <b...@freeuk.com> writes:
>>> [...]
>>>> (I suspect I'm the only one here who has attempted to make a C with a
>>>> 64-bit int, to try it out. It didn't work, but there were many other
>>>> reasons for that.
>>>
>>> I've worked on implementations with 64-bit int. One such system had
>>> 8-bit char and 64-bit short, int, and long. Another had 8-bit char,
>>> 32-bit short, and 64-bit int and long. I worked with C and C++ code
>>> running under a Unix-based OS, though I was not a direct author of
>>> maintainer of that code. I don't recall any problems due to int being
>>> wider than 32 bits. There may well have been some problems that I
>>> wasn't aware of. (The systems were Cray vector computers.)
>> I was thinking of a more contemporary scenario, one where there are
>> billions of lines of existing code that may have assume a certain 'int'
>> size that would be put to the test.
>>
>> A large proportion of which would not have been written by the sort of
>> exacting programmers who would have been allowed near 1970s
supercomputers.
>>> As you know, making int 64 bits is a choice of an implementation, not a
>>> change to the language. Making char 8 bits and int 64 bits means that
>>> you can't have predefined 16-bit and 32-bit integer types (short can be
>>> one or the other, or neither). That, I speculate, is part of the reason
>>> modern 64-bit systems tend to have 32-bit int.
>> So you only have 'short' to select between 16-bit and 32-bit ints? I
>> admit that can be a bit of quandry, but surely it is a ridiculous reason
>> to deny language users a proper 64-bit type!
>>
> You'd have to either make int32_t or similar a built in type, or
you'd have to
> invent an extension like "medium" . Otherwise with the rules as they
are you
> can have 16 bit or 32 bit shorts, but not both, and long has to be at
least
> as long as int.

This is just bikeshedding. An acceptable solution might have been:

* Keep int as 32 bits
* Make long 64 bits across all platforms (at present only Linux 64
has that size)
* Make integer constants 64 bits
* Promote all integer types to 64 bits

In short, use 'long' for the name of the 64-bit type, similar to a a
number of other languages, AND make that the default type for constants
and evaluation.

> int is the natural type to use for the number of children in a family.
> int is the natural type to use for the number of employees in a company.
> int is the natural type to use for the number of sound samples in an
audio signal.
>
> In the first case it is unlikely to go above ten and can't go above
thirty.

Here u8 would be the natural size, if you had to represent a million
such families in a program.

> In the second case it could go over 16 thousand but not over 2 billion.
> In the third case it could go extremely high, but not above the capacity
> of the machine to process the signal.

> The first case is the most common type of data. Most integers in programs
> are small. But normally iterating over children won't be. a performance
> bottleneck. If we've got a 64 bit machine, we can afford the extra
padding bytes.
>
> The third case is more interesting. Iterating over audio samples
could be enough
> of a bottle neck that we need to use an efficient type. And a 44100
MHz stereo
> sample will, break the 2 billion mark at about 8 hours. Unlikely
you'd have a
> sample that long, but not impossible (the movie Shoah is 9 hours 21
minutes).

Yes, but now there is a realistic limit that you have to worry about.
Here, 4 extra bytes compared with the potential size of the data
(billions of 8 or 16-bit samples) is irrelevant.

> However if you're going to slurp in the sundtrack to Shoah as one
signal and
> process it, you will certainly have a 64 bit machine. So the C system
where int is
> the "natural integer type to use on the machine" is ideal here.

The default Int is predominantly used for standalone variables,
parameters, and named constants. There will be a max of a few thousand
value across a program, many of them sharing memory (as they will occupy
the same stack frame memory since only a handful of all functions are
active at any one time).

It is when you create data structures that you need to consider using
narrower types.

Now let's look at some situations where 32-bit int might not be quite
enough:

* The sizeof() of a data structure or type
* The number of bytes of memory ...
* ... or in a file
* ... or in a storage device
* ... or in a string
* The number of bits in a data structure (8 times as many bytes)
* The number of pixels in all frames of a 3 hour 60fps 4K movie (2500
billion)
* Doing calculations with 32-bit quantities
* Integer inputs from a command line
* The world population
* The age of the earth in years
* The number of milliseconds in a month
* ...

2 billion is just too narrow for comfort for many things. And in C,
integer constants have a type of `int`, so a simple calculation like
1<<33 will overflow.

With 16-bit machines, ints were 16 bits.
With 32-bit machines, ints were 32 bits.
But with 64-bit machines, ints are still 32 bits?

With 8-bit machines, you needed to think twice using 16-bit values,
since support was very limited, and inefficient. But 64-bit machines
HAVE that support, and in spades! 128-bit values become viable.

So why the reluctance to use 64-bit in C /as the default/? It's like
having a default 4-bit int on an 8-bit device.

My theory is that it would break too much code.

Re: you think rust may outthrone c?

<WL8xM.59821$8_8a.50237@fx48.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx48.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: you think rust may outthrone c?
Newsgroups: comp.lang.c
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com> <789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com> <u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad> <u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad> <u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me> <u9trgp$1stmg$1@dont-email.me> <87zg3hnmdb.fsf@nosuchdomain.example.com> <ua1fqr$2bksk$1@dont-email.me> <b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com>
Lines: 41
Message-ID: <WL8xM.59821$8_8a.50237@fx48.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 29 Jul 2023 13:47:34 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 29 Jul 2023 13:47:34 GMT
X-Received-Bytes: 3332
 by: Scott Lurndal - Sat, 29 Jul 2023 13:47 UTC

Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>On Friday, 28 July 2023 at 23:35:23 UTC+1, Bart wrote:
>> On 27/07/2023 21:13, Keith Thompson wrote:
>> > Bart <b...@freeuk.com> writes:
>> > [...]
>> >> (I suspect I'm the only one here who has attempted to make a C with a
>> >> 64-bit int, to try it out. It didn't work, but there were many other
>> >> reasons for that.
>> >
>> > I've worked on implementations with 64-bit int. One such system had
>> > 8-bit char and 64-bit short, int, and long. Another had 8-bit char,
>> > 32-bit short, and 64-bit int and long. I worked with C and C++ code
>> > running under a Unix-based OS, though I was not a direct author of
>> > maintainer of that code. I don't recall any problems due to int being
>> > wider than 32 bits. There may well have been some problems that I
>> > wasn't aware of. (The systems were Cray vector computers.)
>> I was thinking of a more contemporary scenario, one where there are
>> billions of lines of existing code that may have assume a certain 'int'
>> size that would be put to the test.
>>
>> A large proportion of which would not have been written by the sort of
>> exacting programmers who would have been allowed near 1970s supercomputers.
>> > As you know, making int 64 bits is a choice of an implementation, not a
>> > change to the language. Making char 8 bits and int 64 bits means that
>> > you can't have predefined 16-bit and 32-bit integer types (short can be
>> > one or the other, or neither). That, I speculate, is part of the reason
>> > modern 64-bit systems tend to have 32-bit int.
>> So you only have 'short' to select between 16-bit and 32-bit ints? I
>> admit that can be a bit of quandry, but surely it is a ridiculous reason
>> to deny language users a proper 64-bit type!
>>
>You'd have to either make int32_t or similar a built in type, or you'd have to
>invent an extension like "medium" . Otherwise with the rules as they are you
>can have 16 bit or 32 bit shorts, but not both, and long has to be at least
>as long as int.
>int is the natural type to use for the number of children in a family.

Can a family have a negative number of children? No. 'unsigned int'
then becomes the natural type to use for the number of children in
a family. etc.

Re: you think rust may outthrone c?

<ua36jq$2kotc$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Sat, 29 Jul 2023 15:10:03 +0100
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <ua36jq$2kotc$1@dont-email.me>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <87zg3hnmdb.fsf@nosuchdomain.example.com>
<ua1fqr$2bksk$1@dont-email.me>
<b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com>
<WL8xM.59821$8_8a.50237@fx48.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Jul 2023 14:10:02 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="4499a152026011cd009e4bb37a25d4eb";
logging-data="2778028"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/A4YFg7TXxl15jm/XSSXE9E4U/uaZZtYs="
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.13.0
Cancel-Lock: sha1:XBQ1pqSyRBcBM+ZMW42n/X7MxVY=
In-Reply-To: <WL8xM.59821$8_8a.50237@fx48.iad>
 by: Bart - Sat, 29 Jul 2023 14:10 UTC

On 29/07/2023 14:47, Scott Lurndal wrote:
> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>> On Friday, 28 July 2023 at 23:35:23 UTC+1, Bart wrote:
>>> On 27/07/2023 21:13, Keith Thompson wrote:
>>>> Bart <b...@freeuk.com> writes:
>>>> [...]
>>>>> (I suspect I'm the only one here who has attempted to make a C with a
>>>>> 64-bit int, to try it out. It didn't work, but there were many other
>>>>> reasons for that.
>>>>
>>>> I've worked on implementations with 64-bit int. One such system had
>>>> 8-bit char and 64-bit short, int, and long. Another had 8-bit char,
>>>> 32-bit short, and 64-bit int and long. I worked with C and C++ code
>>>> running under a Unix-based OS, though I was not a direct author of
>>>> maintainer of that code. I don't recall any problems due to int being
>>>> wider than 32 bits. There may well have been some problems that I
>>>> wasn't aware of. (The systems were Cray vector computers.)
>>> I was thinking of a more contemporary scenario, one where there are
>>> billions of lines of existing code that may have assume a certain 'int'
>>> size that would be put to the test.
>>>
>>> A large proportion of which would not have been written by the sort of
>>> exacting programmers who would have been allowed near 1970s supercomputers.
>>>> As you know, making int 64 bits is a choice of an implementation, not a
>>>> change to the language. Making char 8 bits and int 64 bits means that
>>>> you can't have predefined 16-bit and 32-bit integer types (short can be
>>>> one or the other, or neither). That, I speculate, is part of the reason
>>>> modern 64-bit systems tend to have 32-bit int.
>>> So you only have 'short' to select between 16-bit and 32-bit ints? I
>>> admit that can be a bit of quandry, but surely it is a ridiculous reason
>>> to deny language users a proper 64-bit type!
>>>
>> You'd have to either make int32_t or similar a built in type, or you'd have to
>> invent an extension like "medium" . Otherwise with the rules as they are you
>> can have 16 bit or 32 bit shorts, but not both, and long has to be at least
>> as long as int.
>> int is the natural type to use for the number of children in a family.
>
> Can a family have a negative number of children? No. 'unsigned int'
> then becomes the natural type to use for the number of children in
> a family. etc.
>

I'd be wary of such conclusions.

Sometimes negative values come up even for quantities that physically
cannot be zero. So I can't have a negative number of actual dollar
bills, but if I owed you $10 and only have $6, my net worth, or disposal
amount, is -$4.

Besides if I wanted to know how many more children family A has than
family B, if's quite possible that `a - b` could yield a negative value,
if B in fact has more children.

(I know I suggested `u8` (uint8_t) for this in my other post, but I
didn't want to open this can of worms. Besides, calculations with such
quantities will be done using full-width signed integers - you can have
your negative results.)

Re: you think rust may outthrone c?

<20230729082308.56@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: you think rust may outthrone c?
Date: Sat, 29 Jul 2023 15:30:52 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <20230729082308.56@kylheku.com>
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com>
<789db599-e078-485f-bf16-32865c1eb970n@googlegroups.com>
<u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad>
<u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad>
<u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me>
<u9trgp$1stmg$1@dont-email.me> <87zg3hnmdb.fsf@nosuchdomain.example.com>
<ua1fqr$2bksk$1@dont-email.me>
<b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com>
<WL8xM.59821$8_8a.50237@fx48.iad>
Injection-Date: Sat, 29 Jul 2023 15:30:52 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="892a16121661d52822fd2a02c481f346";
logging-data="2792762"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+loA3i6nx/SIItX8Uw/qNQrKK+YiSPx0k="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:sVuXSOUaExAInNkMmdHcGa3RUUc=
 by: Kaz Kylheku - Sat, 29 Jul 2023 15:30 UTC

On 2023-07-29, Scott Lurndal <scott@slp53.sl.home> wrote:
> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>
>>You'd have to either make int32_t or similar a built in type, or you'd have to
>>invent an extension like "medium" . Otherwise with the rules as they are you
>>can have 16 bit or 32 bit shorts, but not both, and long has to be at least
>>as long as int.
>>int is the natural type to use for the number of children in a family.
>
> Can a family have a negative number of children? No. 'unsigned int'
> then becomes the natural type to use for the number of children in
> a family. etc.

Sure; if you don't mind problems like not being able to do basic
derivation:

a < b + c

a - c < b # subtract c from both sides

If a, b, and c are small numbers like number of children in a family,
the above holds for signed int. You can "fearlessly" refactor
inequality expressions in code.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal
Mastodon: @Kazinator@mstdn.ca

Re: you think rust may outthrone c?

<QIaxM.23190$KJXf.14075@fx05.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx05.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: you think rust may outthrone c?
Newsgroups: comp.lang.c
References: <ebb9e01a-6369-4629-8b38-11d28df63693n@googlegroups.com> <u9rcgd$1h7l5$1@dont-email.me> <WRawM.202896$TPw2.151582@fx17.iad> <u9rnnv$1iftl$1@dont-email.me> <WNdwM.224816$GMN3.36273@fx16.iad> <u9s1v2$1jhg7$1@dont-email.me> <u9tko8$1s9cs$1@dont-email.me> <u9trgp$1stmg$1@dont-email.me> <87zg3hnmdb.fsf@nosuchdomain.example.com> <ua1fqr$2bksk$1@dont-email.me> <b7ada3e0-82a9-45f1-9635-9993667fe9c5n@googlegroups.com> <WL8xM.59821$8_8a.50237@fx48.iad> <ua36jq$2kotc$1@dont-email.me>
Lines: 56
Message-ID: <QIaxM.23190$KJXf.14075@fx05.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Sat, 29 Jul 2023 16:00:48 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Sat, 29 Jul 2023 16:00:48 GMT
X-Received-Bytes: 3970
 by: Scott Lurndal - Sat, 29 Jul 2023 16:00 UTC

Bart <bc@freeuk.com> writes:
>On 29/07/2023 14:47, Scott Lurndal wrote:
>> Malcolm McLean <malcolm.arthur.mclean@gmail.com> writes:
>>> On Friday, 28 July 2023 at 23:35:23 UTC+1, Bart wrote:
>>>> On 27/07/2023 21:13, Keith Thompson wrote:
>>>>> Bart <b...@freeuk.com> writes:
>>>>> [...]
>>>>>> (I suspect I'm the only one here who has attempted to make a C with a
>>>>>> 64-bit int, to try it out. It didn't work, but there were many other
>>>>>> reasons for that.
>>>>>
>>>>> I've worked on implementations with 64-bit int. One such system had
>>>>> 8-bit char and 64-bit short, int, and long. Another had 8-bit char,
>>>>> 32-bit short, and 64-bit int and long. I worked with C and C++ code
>>>>> running under a Unix-based OS, though I was not a direct author of
>>>>> maintainer of that code. I don't recall any problems due to int being
>>>>> wider than 32 bits. There may well have been some problems that I
>>>>> wasn't aware of. (The systems were Cray vector computers.)
>>>> I was thinking of a more contemporary scenario, one where there are
>>>> billions of lines of existing code that may have assume a certain 'int'
>>>> size that would be put to the test.
>>>>
>>>> A large proportion of which would not have been written by the sort of
>>>> exacting programmers who would have been allowed near 1970s supercomputers.
>>>>> As you know, making int 64 bits is a choice of an implementation, not a
>>>>> change to the language. Making char 8 bits and int 64 bits means that
>>>>> you can't have predefined 16-bit and 32-bit integer types (short can be
>>>>> one or the other, or neither). That, I speculate, is part of the reason
>>>>> modern 64-bit systems tend to have 32-bit int.
>>>> So you only have 'short' to select between 16-bit and 32-bit ints? I
>>>> admit that can be a bit of quandry, but surely it is a ridiculous reason
>>>> to deny language users a proper 64-bit type!
>>>>
>>> You'd have to either make int32_t or similar a built in type, or you'd have to
>>> invent an extension like "medium" . Otherwise with the rules as they are you
>>> can have 16 bit or 32 bit shorts, but not both, and long has to be at least
>>> as long as int.
>>> int is the natural type to use for the number of children in a family.
>>
>> Can a family have a negative number of children? No. 'unsigned int'
>> then becomes the natural type to use for the number of children in
>> a family. etc.
>>
>
>I'd be wary of such conclusions.
>
>Sometimes negative values come up even for quantities that physically
>cannot be zero. So I can't have a negative number of actual dollar
>bills, but if I owed you $10 and only have $6, my net worth, or disposal
>amount, is -$4.
>
>Besides if I wanted to know how many more children family A has than
>family B, if's quite possible that `a - b` could yield a negative value,
>if B in fact has more children.

if (a_children > b_children) x else y.


devel / comp.lang.c / you think rust may outthrone c?

Pages:123456789101112131415161718192021222324252627282930313233343536373839
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor