On Thursday, 14 July 2016 at 20:01:54 UTC, Walter Bright wrote:
On 7/14/2016 11:49 AM, Steven Schveighoffer wrote:
In C++, the compiler has to reload x, because it may have
changed.
That's right. I learned that the hard way, when the original
optimizer would assume that x hadn't changed. It broke a
surprising amount of code.
It also means that the utility of const in C++ is extremely
limited.
Walter, I hope you were just in a rush. Because I think you meant
to say, "the utility of const in C++ for *optimizing code* is
extremely limited". If you really think that the optimizer is the
primary audience for language features, then ... well that would
surprise me given D's design, which generally seems quite mindful
of "humans are the primary audience".
Though at times I do feel people use "auto" when they should
state the type they expect (because then the compiler could help
detect changes which break intent, that might otherwise compile
just fine).