Sujet : Re: constexpr keyword is unnecessary
De : ifonly (at) *nospam* youknew.org (Opus)
Groupes : comp.lang.cDate : 21. Oct 2024, 02:02:07
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vf496f$kapk$1@dont-email.me>
References : 1 2 3 4 5 6 7
User-Agent : Mozilla Thunderbird
On 20/10/2024 20:28, Keith Thompson wrote:
David Brown <david.brown@hesbynett.no> writes:
[...]
I know there are compilers that don't support VLAs at all - that's
fair enough (and that's why I specifically mentioned it). We can
expect that compilers that can't handle VLAs at all will not support
C23 constexpr, or any suggested C++ style extensions to the semantics
of "const".
Why would we expect that?
IIRC, Microsoft has decided not to support VLAs in its C compiler. If
they chose not to support constexpr, they could not claim C23 conformance.
Indeed. From the working draft I have of C23, while VLAs are optional, constexpr is not as far as I can tell.
MS has a long history of being reluctant to be compliant with anything past C89 - it took them ages to finally support C99, and after that, they added strictly what was not optional from what I see.
More generally speaking, it looks like MS hasn't really cared about C ever since the late 90's - early 2000's where they entirely focused on C++. The Windows API is still C in itself for the most part, but it doesn't require anything past C89 (again that I know of / remember). Ditto for drivers.
So I don't think there is any internal incentive to keep up with C standards, except for the strict minimum so that developers can't say that MSVC is completely obsolete.
Regarding const vs constexpr, it looks like some people have a hard time understanding the concept of not breaking existing behavior, which has been one of C's strong points and largely explains why it's still being used today. And as I understand, one argument was that const should be constexpr in some contexts where it's considered "obvious" (but not in others). Context-dependent keywords are not a fantastic idea.
Now may people tend to conflate 'constants' with 'literals' in C. And don't realize that a const-qualified variable is still a 'variable', not a 'constant' in the usual sense in CS. I personally think constexpr is a welcome addition in C. The naming may be questionable, or not. Sure it was borrowed from C++. From what I know, there has been a rule between the C and the C++ standard committees for a while, that using different naming and keywords for what's the same feature in the two languages should be avoided. And I guess it makes sense.