Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <v2sv8a$2u3d4$1@dont-email.me>
Deutsch   English   Français   Italiano  
<v2sv8a$2u3d4$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!feeder8.news.weretis.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: David Brown <david.brown@hesbynett.no>
Newsgroups: comp.lang.c
Subject: Re: C23 thoughts and opinions
Date: Sat, 25 May 2024 17:14:18 +0200
Organization: A noiseless patient Spider
Lines: 78
Message-ID: <v2sv8a$2u3d4$1@dont-email.me>
References: <v2l828$18v7f$1@dont-email.me>
 <00297443-2fee-48d4-81a0-9ff6ae6481e4@gmail.com>
 <v2lji1$1bbcp$1@dont-email.me>
 <9be0c55c-38f8-496c-b335-84ad281e1753@gmail.com>
 <v2nc5h$1oban$1@dont-email.me>
 <c5866b5a-0314-4e70-af56-a86b63986b0c@gmail.com>
 <v2nfai$1ougd$1@dont-email.me>
 <cf267279-e9cf-415f-898c-f5830a997529@gmail.com>
 <87ed9s42sb.fsf@nosuchdomain.example.com>
 <f5774ff3-d2b0-4787-b16c-3b193dc418ef@gmail.com>
 <87bk4v2du1.fsf@nosuchdomain.example.com>
 <ec20f752-6132-40f5-a4e8-f884746d2f3a@gmail.com>
 <87v8330xq3.fsf@nosuchdomain.example.com>
 <97c17a49-a940-42ff-83b8-df755fb6e88e@gmail.com>
 <v2sgm6$2rle2$1@dont-email.me>
 <3510a9be-2962-4f8a-a040-62e2716eed92@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 25 May 2024 17:14:18 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="5acf865375c1c1cdc2a566d884dbbc5b";
	logging-data="3083684"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19kFo0XuZOjq7sTRbWL4GHWBr2At907AwI="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:OCaImNVP6p6DLCdYR7wRtd6Csnk=
Content-Language: en-GB
In-Reply-To: <3510a9be-2962-4f8a-a040-62e2716eed92@gmail.com>
Bytes: 5374

On 25/05/2024 13:19, Thiago Adams wrote:
> Em 5/25/2024 8:05 AM, David Brown escreveu:

>>
>> In C (not C++), defining an object as "constexpr" gives you two things 
>> compared to defining it as "const".  One is that its value can be used 
>> when you need a constant expression according to the rules of the 
>> language (such as for the size of an array in a struct).  The other is 
>> that it gives a compile-time error if its initialiser is not itself a 
>> constant expression - and that means an extra check and protection 
>> against some kinds of programmer errors, and extra information to 
>> people reading the code.
>>
>> I don't expect it to make a difference in generated code from an 
>> optimising compiler, in comparison to objects declared with "const".
>>
>>
> 
> In my view , for this sample constexpr generates noise.

I don't share that opinion, but I understand it.

> It also can make 
> the compilation slower, otherwise, why not everything constexpr by defaul?

That claim, on the other hand, is very strange.  Making everything 
constexpr by default would be a massive change to the language that 
would break all but the most negligible of existing code.  And I can 
think of no particular reason why constexpr would slow down compilation, 
at least to any measurable degree.

> I still didn't find a useful usage for constexpr that would compensate 
> the mess created with const, constexpr. 

I don't need a feature to "compensate" for anything to be useful.  I 
don't need it to be perfect to be useful.  There's a few things about 
constexpr in C23 that I think are poor decisions, unreasonable 
restrictions, or suboptimal integration with other language features 
(like static_assert) - such as the array limitations you've found.  That 
will mean I can't use constexpr as much as I'd like, or as much as I do 
in C++.  But even if there is just one situation where I think using 
constexpr is neater or clearer than using enum, #define, or some other 
technique, then I will use constexpr in that one situation.  Why are you 
so insistent on throwing it out completely just because it doesn't do 
everything you might want?


> I already saw ( I don't have it 
> now ) proposals to make const more like constexpr in C. In C++ const is 
> already a constant expression!

No, it is not - but sometimes a const object with particular 
characteristics can be used in situations where you would otherwise need 
a constant expression.  I mentioned earlier that I find this convenient 
in C++ - Keith said it was inconsistent, which is also true.  I think 
that to a large extent, if C "const" had acquired the additional 
features of C++ "const" (excluding the different linkage for file-scope 
"const" objects, since that would be a breaking change) then it would 
have done everything C23 "constexpr" does today.  I personally would 
have been fine with that as a solution.  But I fully appreciate that it 
would have been inconsistent and perhaps hard to specify - you'd would 
have the situation that /some/ const objects could be used for things 
like static initialisers, while others could not.

> The justification for C was VLA. They should consider VLA not VLA if it 
> has a constant expression. In other words, better break this than create 
> a mess.
> #define makes the job of constexpr.
> 

#define is one way to make named items that can be used in constant 
expressions, yes.  But if it can be done using #define or constexpr, I 
think constexpr is the neater choice.  Opinions can vary - that's my 
opinion.