C++ Committee Meeting Trip Report: Lenexa, 2015
With the next standard still pretty far away, the committee focused on advancing the language with some exciting and long awaited new features such as modules, concepts, resumable functions, etc, etc. The default comparisons story continued to unfold and had not ended yet. Bjarne presented two tectonic proposals, one of which (the dot operator) had even survived.
The meeting was held in Lenexa, Kansas, a small town near Kansas City (which, interestingly enough, is mostly in Missouri, not Kansas). It was hosted by Perceptive Software, recently acquired by Lexmark. Building was constructed very recently; Google’s Street View shows a field of grass at that location.
I spent most of the time in the Language Evolution Working Group (EWG) that focuses on proposals to advance the language (as opposed to, for example, the Library [Evolution] WG that only targets the standard library).
There was also an evening session of the Reflection Study Group (SG7) that I was able to attend. I didn’t quite understand what this is all about at first and how is this useful for C++. Fortunately, a post-meeting discussion cleared things a bit. It appears that the main problems SG7 is trying to solve with reflection include
- better run-time error messages (like in assert, but without macros),
- easier serialization/de-serialization (see also N4393), and
- GUI building like in Java (still unclear why reflection is essential here.
Out of all the papers presented, the following have the most potential impact on compilers in C++17 and beyond:
Modules
Proposal: N4465.
Modules sparked a very long and spirited discussion that time; the paper was more polished and there’s even standard wording available (N4466). However, some basic aspects did not receive approval from the group, so the proposal will [slightly] change and come back again to the next meeting.
That time, it was a little bit less scary than before, chiefly because there were more details. However, Chandler Carruth (Google, clang) did say that “[Modules are] the most complex feature to be implemented” and what they had already implemented at Google was not word-for-word compatible with Microsoft (the main driver of this proposal).
Microsoft insisted that their implementation of modules is already in production, but admitted that there were tweaks to make certain macros “leak” from a module, controlled with a command line option. The latter was not in the proposal and actually goes against its spirit.
There was a lot of push from many people for this proposal to go forward (Bjarne, Gaby, others as well) and I noticed that other proposals were already being reviewed in context of modules (as if modules had already been accepted into the standard). So it is reasonable to expect that modules will be in C++17. This is not a hard guarantee, though.
N4513 Transaction Memory TS (Technical Specification, not International Standard)
Proposal: N4513.
Briefly, this is a request to add facilities to start, end and rollback a transaction to the language. It it supposed to help writing concurrent algorithms without the need to care about synchronization; if a data race is detected by the system, one of the threads automatically reverts its memory state to the start of the transaction and tries again. It went though Core Language Working Group (CWG) reviewing comments from National Bodies (NBs). I wasn’t there, but judging by the script, no significant change had been requested/approved.
Concepts
Proposal: N4361.
Concepts - in their current form - essentially are formalized and extended
SFINAE; the proposal also included a terse syntax for a template declaration
(without the template <...>
header).
The proposal went though the CWG reviewing comments from National Bodies. Will probably go through voting again on the next meeting, no substantial changes, but might add constrained variable declarations.
Tweaks to streamline concepts syntax were essentially rejected this time, people generally did not want to postpone publishing of this TS. Might come back later, but after the first publication.
Exception specifications to be part of the type system
Proposal: N4518.
It looked like only noexcept
and throw()
were going to make it into the
type system. Many voted for removing throw(type list)
entirely. Consensus was
that was not going to be removed (now), yet at the same time not added to the
type system.
Resumable Functions
Proposal: N4402.
This proposal introduces several new keywords (yeild
and await
) to help
building light-weight stack-less coroutines that can be suspended at certain
points and resumed later by their caller.
It was going through Core at the meeting; will likely be accepted at the next one. There was a competing proposal (Resumable Expressions, N4453), but it was shut down mainly because (I think) people wanted at least something of the sort out there ASAP and didn’t want to wait for a unified proposal.
Default Comparisons
Proposal: N4475.
The proposal suggests generation of a declaration and the definition of comparison operators on-demand for class types. Generation is suppressed for classes with certain members (like pointers). A relatively minor feature from the implementation standpoint.
This time, it was received well and will probably be a part of C++17. Although Lawrence Crowl (former Sun, now Google) objected strongly to having this and proposed to introduce a library solution instead with well-defined semantics (mainly for floating point); it seems that his solution can later be plugged into language-level default comparisons and not many people wanted to postpone the comparisons on that account. Especially after a passionate talk by Bjarne on how not to do things in the committee.
Rewording inherited constructors
This is core issue 1941.
It is mostly about using the exact same signature from the parent class instead of declaring (a set of) new constructors in the child. This proposal was received well and we’ll have to re-implement parts of inheriting constructors machinery.
Operator Dot (R2)
Proposal: N4477.
Bjarne gave many compelling use cases (smart references, pimpl pattern, etc, etc) and the proposal received generally good, just a little bit controversial, feedback. We’ll probably be overloading dot in C++17… (what would three dots mean after that goes through, I wonder?)
Static if resurrected
Proposal: N4461.
The proposal is about having a new language construct analogous to if
, but
with the condition computable at compile time. If it evaluates to true, the compiler
will only instantiate the “true” part of the if
statement. The “false” part is still
parsed and syntactically checked, but the dependent stuff in there is not
instantiated. Was received well and will be back on the next meeting.
noexcept(auto), again
Proposal: N4473.
This is about automatic deduction of the noexcept specification from the body of an inline function. Well received in general, some concerns were raised about hard-to-spot API breakage. Will probably return to the next meeting for voting.
Misc
There were 3 papers on roughly the same subject of run-time contracts, each with its unique take on the problem. The committee asked (quite strongly) for a unified proposal to solve all the problems with preferably one syntax and definitely in one paper. It is likely that one of these days we’ll see that proposal.
Unified Call Syntax proposed by Bjarne didn’t receive approval; there was strong resistance from [almost] everybody from Google. Also, all compiler developers voted uniformly and strongly against.
References:
- Most of the papers mentioned in the report can be found in the pre-meeting mailing (note that some papers were produced during the meeting and had not been published anywhere)
- Latest draft of C++ that those documents refer to is N4431
- The C++ Committee
- The committee meetings schedule