3 ms·
> But I would expect "auto x = y;" to create a new variable by copying Why would you expect that? There are plenty of examples of other referentially transpare
by kobeya 9y ago
> But I would expect "auto x = y;" to create a new variable by copying
Why would you expect that? There are plenty of examples of other referentially transparent languages where "x = y" means x and y refer to the same thing, not different things (one newly created) initialized to the same value. Maybe you expect it to work the way it does because that more closely resembles how C++ has worked for you in the past, which is a bit of a circular argument.
> Of course you may now say that one should have done it right from the start, but this is then an argument about the initial decisions in the late 80s, not about the use of auto in C++11.
Yes, that's exactly the point I am making.
- exprA 9y agoAre you sure you're making a point – because I can't see one. Seems more about unnecessary bitching about C++ being different from [some-different-language]. If they could do anything more stupid as introducing a galling difference and a special case to variable initialisation with auto, it would be to do exactly that, but because “some other languages work more like that”.