Deutsch   English   Français   Italiano  
<v2ngf7$1p3o2$2@dont-email.me>

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

Path: ...!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: Thu, 23 May 2024 15:31:19 +0200
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <v2ngf7$1p3o2$2@dont-email.me>
References: <v2l828$18v7f$1@dont-email.me>
 <00297443-2fee-48d4-81a0-9ff6ae6481e4@gmail.com>
 <v2lji1$1bbcp$1@dont-email.me> <20240523154331.000063da@yahoo.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 23 May 2024 15:31:19 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f9e44f8620308395335310dec31cb554";
	logging-data="1871618"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1/LYFixA3CmIZxoVWImM8ojMNxPgUtR6V8="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.11.0
Cancel-Lock: sha1:tss5hD5aRD4zsmWCgGEYvvibDh4=
In-Reply-To: <20240523154331.000063da@yahoo.com>
Content-Language: en-GB
Bytes: 2332

On 23/05/2024 14:43, Michael S wrote:
> On Wed, 22 May 2024 22:11:44 +0200
> David Brown <david.brown@hesbynett.no> wrote:
> 
>>
>> I will definitely use that.  Sometimes I want a constant expression
>> for things like array sizes or static initialisers, and want to
>> calculate it.  constexpr gives you that without having to resort to
>> macros.
> 
> I don't say that everything that can be done with C23 constexpr can be
> done with enum, but for uses like ones you mentioned above, 90%
> probably can be done with enum.
> 

I realise that, and use enum for such things today.  But IMHO constexpr 
is neater and it also covers the other 10%.

I think most of the new features of C23 neaten up the language a bit. 
They are not game-changers - I doubt that any of them will significantly 
change the way anyone writes their code (especially for those already 
happy with gcc or clang extensions).  But there are several things here 
that can make code a little nicer.

So yes, I /could/ use enum constants for things that are not 
enumerations.  I /did/ use them for that.  But going forward with C23, 
I'll use constexpr instead.