Sujet : Re: constexpr keyword is unnecessary
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 13. Oct 2024, 16:03:08
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vegnfd$ngn6$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 13.10.2024 16:41, Bonita Montero wrote:
Am 13.10.2024 um 16:33 schrieb Janis Papanagnou:
This is not the least convincing. Since you seem to express only a
language/compiler-internal theme, not any application programmers'
demand.
I don't understand how people can argue so desperately against a
feature that is so simple and that makes the code more readable.
I'm aware that you are obviously in battle-mode and thus completely
missed that I'm not "against a feature" but just try to understand
the rationale for that. - Again you evaded answering that question,
and I see my suspicion confirmed that there is no gain.
For me, writing int i = 0; and const int i = 0; is perfectly
readable, and (unnecessarily!) adding another keyword degrades
readability.
As a programmer I expect a compiler to be able to detect constant
expressions, I don't want to litter my program code with technical
constructs to individually tell - on a per-statement basis - the
compiler that a specific constant expression should be evaluated
during compile-time and not postponed to run-time. To support a
simple compiler I think it's okay to instruct him explicitly to
spend more effort pre-evaluating constant expressions, say be a
compiler option. But certainly not by spreading keywords across
the code thereby making the code _less readable_.
(And, as you can derive from what I wrote, I find '_Static_eval'
also not increasing readability.)
Janis