2 ms·
>I think most of us understand the historical pressure, It doesn't look that way from the GP's comment: "I really wish they had found a less confusing way to
by jasode 11y ago
>I think most of us understand the historical pressure,
It doesn't look that way from the GP's comment: "I really wish they had found a less confusing way to bolt this move semantics / rvalue references stuff onto C++ ..."
... is actually an example of not understanding (or not being aware of) historical pressure.
If you create a new programming language (e.g. Rust) with a blank slate, you have more flexibility to make semantics "simpler" by rethinking the design of the syntax, the sigils, and the implicit defaults.
Rust syntax accomplishes "move semantics" without double ampersands (&&) sigils and "std::move()".[1] The end result is that Rust syntax looks less cluttered to move ownership around.
The key to Rust's clean syntax is the absence of "historical pressure".
Rust starts from a blank slate without worrying about breaking legacy code. Rust wasn't invented in 1982.
C++ move semantics uses C++1982/C++98 as a starting point and can't use naked variables to let the compiler carry out "moves". Legacy code would be ambiguous and compilation would break. The "rvalues std:move()" was proposed in 2002 and finalized for C++11. They had 9 years for others to challenge Howard's proposal and devise a simpler more elegant way that doesn't break existing code. Nobody came up with an alternative. Hence, the uglier C++ syntax bolted on for "moves" is probably as simple as we're going to get.
[1]http://stackoverflow.com/questions/29490670/how-does-rust-provide-move-semantics http://stackoverflow.com/questions/29490670/how-does-rust-pr...