C++ Logo

SG20

Advanced search

Subject: Re: Constant initialization in C++20
From: Tomas p (pecholt_at_[hidden])
Date: 2019-06-19 03:17:42


Thanks for your comments on this subject. The biggest issue I have here is
that there are already too many C++ keywords allocated just for this topic.
I don't feel anything wrong with is_constant_evaluated since that is a
function and so similarly to other functions it can be ignored unless
needed.

But to allocate a new C++ keyword that should be only for something
fundamental. For example in many programming books and courses list of
keywords is something presented very early. It is something even average
programmers are expected to know and understand. But these new keywords
(consteval, constinit) are not.

Everybody wants a reflection facilities in the language but to me that's
not enough of a reason to include consteval in the keywords list. I have
never heard of someone complaining of missing consteval functionality. So
for that reason these functions could be made special by other means (they
are built in). And it's okay without this keyword user won't be able to
create similar facility on his own because there was never a need for that.

As for constinit it seems that it solves a niche area problem. As you are
saying it's meant for constant initialization which is not constexpr.
Probably used in some embedded area software. Well C++ is used by so many
industries but even if we say this particular usage in embedded is
important from my experience C++ standard adoption in embedded is always
far behind. Currently they are catching on C++11. Does it really make sense
to allocate new keyword then? I wish there could be an attribute for this
purpose something along [[no_unique_address]].

Seeing keyword explosion of keywords only for constant initialization
definitely contributes to a feeling that C++ is expert only language. I
wish it would get more thinking in the committee before it's cast in stone.
I feel like although there are numerous papers from B.Stroustrup and others
about getting more focus on novice and average programmers in the end it
always goes the opposite direction. Keeping the core language additions
minimal is important goal at this point imho.

On Tue, Jun 18, 2019 at 6:07 PM chuck.allison via SG20 <
sg20_at_[hidden]> wrote:

> Well said, Tomas. I think const is sufficient in most instances for
> newcomers, with constexpr presented as needed. Going beyond this can be
> overwhelming and contribute to the belief that C++ is an experts-only
> language. Concepts should presented when they can be understood.
>
> Much of C++ exists to support implementers of systems and libraries. Such
> people are not newcomers to programming, and usually not newcomers to C++.
>
> Chuck
>
>
>
> Sent from my Samsung Galaxy smartphone.
>
> -------- Original message --------
> From: Tomas p via SG20 <sg20_at_[hidden]>
> Date: 6/18/19 12:47 AM (GMT-07:00)
> To: sg20_at_[hidden]
> Cc: Tomas p <pecholt_at_[hidden]>
> Subject: [SG20] Constant initialization in C++20
>
> Hi,
>
> this post is inspired by a presentation of one committee member posted
> recently on reddit.
>
> https://www.reddit.com/r/cpp/comments/c06908/cnow_2019_daveed_vandevoorde_c_constants/
>
> I have no doubts there is a lot of good thoughts and engineering behind
> the works. But this group should discuss suitability for teaching or
> approaching students and other c++ programmers. I would say discussing new
> proposals from teach-ability perspective should be one of the most
> important things for this group. It's arguably more important than new
> guidelines and material - that can be done any time and people do it
> already - but once a new complicated or difficult to teach feature is
> included in the standard there is no way to remove it and so we should
> better get it right.
>
> So I have a question. Do you really think constant
> variables/functions/initialization is going in the right direction? Most
> c++ programmers I know are using only pre-c++11 const keyword. Few
> understand constexpr variables and functions. How many of them do you think
> will be using new keywords in this area - consteval, constinit,
> is_constant_evaluated when it becomes available? Doesn't this work solve
> niche problem? Do you think so many new keywords for constant
> initialization will not be a burden to newcomers and average c++
> programmers?
>
> I am really interested in what this group thinks of it.
> --
> SG20 mailing list
> SG20_at_[hidden]
> http://lists.isocpp.org/mailman/listinfo.cgi/sg20
>



SG20 list run by herb.sutter at gmail.com

Older Archives on Google Groups