Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"structured bindings" vs "decomposition declarations"

Tags:

c++

c++17

Observations:

  • In the P0217R3 proposal (2016-06-24), the structured bindings term is used.
  • In the current working C++1z draft (2016-11-28), the decomposition declarations term is used.
  • In the P0615R0 proposal (2017-03-01), decomposition declarations were renamed to structured bindings.
  • Strikingly, this blogpost (2017-01-09) contains the following text:

Decomposition declarations. [..] Was originally called "structured bindings".

  • Similarly, this question (2017-03-04) contains the following text:

[..] C++17 decomposition declarations (the feature formerly known as "structured bindings").

Questions:

  • Which of these two is the correct and up-to-date term we should use?
  • Why there are two names for the same concept?
  • If decomposition declarations were really renamed to structured bindings, what is the reason?
like image 583
s3rvac Avatar asked May 11 '17 06:05

s3rvac


1 Answers

The new correct name will be a "structured binding declaration", based on wording in P0615. Basically, in:

auto [x,y] = Point(4,2);

The full statement is known as a "structured binding declaration", while the identifiers x and y are known as "structured bindings". These will be the official terms in C++17. Indeed, the latest draft section is now titled Structured Binding Declarations.


The issue is that there are two concepts, that need two different names - so the original wording paper used decomposition declaration for the declaration statement (the term "structured binding" did not appear in the wording at all). However, for most users, this is silly because there's only one concept - the structured binding - so having two different names is harder to learn. Particularly confusing if compiler error messages used "decomposition declaration" in their messages. Regardless of the use of the term "decomposition declaration," the name of the feature has always been structured bindings.

In Kona, EWG decided to stick with the two names, but at least have them sound closely related.

like image 114
Barry Avatar answered Sep 20 '22 00:09

Barry