On Mon, Nov 27, 2017 at 4:07 PM, smaug <sm...@welho.com> wrote: > On 11/28/2017 12:53 AM, Jeff Gilbert wrote: > >> ranged-for issues are the same as those for doing manual iteration, >> > It is not, in case you iterate using > for (i = 0; i < foo.length(); ++i) > And that is the case which has been often converted to ranged-for, with > bad results. > > And auto makes code reading harder. It hides important information like > lifetime management. > It happens easily with auto that one doesn't even start to think whether > nsCOMPtr/RefPtr should be used there. >
This statement seems perhaps a touch to universalist; it may be the case that it makes it harder for *you* to read, but I find it makes it easier for me to read. I also don't think it's a coincidence that it's a common feature of modern languages (Rust and Go, to name just two), so I suspect I'm not alone in thinking auto is a good thing. As for the lifetime question, can you elaborate on the scenario you are concerned about. Is it something like: T *foo() { return new T(); } void bar() { auto t = foo(); } Where you think that t should be assigned to a smart pointer? (Obviously, there are ways for this to cause UAF as well, though this one is a leak). -Ekr _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform