<html><head><meta http-equiv="Content-Type" content="text/html charset=koi8-r"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>I'm not Geoff, yet I'd like to offer my perspective on the specific examples you provided.</div><br><div><div>03 янв. 2014 г., в 4:12, Antti Koivisto &lt;<a href="mailto:koivisto@iki.fi">koivisto@iki.fi</a>&gt; написал(а):</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>auto&amp; cell = toRenderTableCell(*renderer); // right</div><div>RenderTableCell&amp; cell =&nbsp;toRenderTableCell(*renderer); &nbsp;// wrong</div></blockquote><div><br></div><div>I can't agree with this example. With auto, I don't know if it's a raw pointer, a reference, or a smart pointer (we have toXXX functions that return all of those). I also cannot Cmd+click on anything to go to the class definition, and when I Cmd-click on toRenderTableCell, I presumably get into some unreadable macro.</div><div><br></div><div>Overall, auto makes the code very opaque here.</div><br><blockquote type="cite"><div>for (auto&amp; source : descendantsOfType&lt;HTMLSourceElement&gt;(*this)) // right</div><div>for (const HTMLSourceElement&amp; source : descendantsOfType&lt;HTMLSourceElement&gt;(*this)) // wrong</div></blockquote><div><br></div><div>I think that this is borderline OK, and may even be allowed by the latest proposal, although the win is so small that maybe we shouldn't? I don't really see how the first line is better than the second one in any way.</div><br><blockquote type="cite"><div>auto properties = std::make_unique&lt;PropertiesVector&gt;(); &nbsp;//right</div><div>std::unique_ptr&lt;PropertiesVector&gt;&nbsp;properties&nbsp;= std::make_unique&lt;PropertiesVector&gt;(); //wrong</div></blockquote><div><br></div><div>Agreed. I think that this is also allowed by Geoff's proposal.</div><br><blockquote type="cite"><div>This rule is already widely deployed and I think the code readability has improved.</div><div><br></div><div>- Use "auto" when the type is irrelevant. This covers things like iterators and adapter classes:</div><div><br></div><div>auto sourceDescendants = descendantsOfType&lt;HTMLSourceElement&nbsp;&gt;(*this));</div></blockquote><div><br></div><div>So do we need auto or auto&amp; here? I would know how to answer this question immediately if it was an explicit type, but I don't know how to answer it with auto in this particular case.</div><div><br></div><blockquote type="cite"><div>It might also cover smart pointer usage like your example and multiline expansions of setSize(foo-&gt;size()).</div><div><br></div><div>- Use "auto" when type is obvious for people with basic familiarity with a subsystem:</div><div><br></div><div>auto&amp; style = renderer.style();</div></blockquote><br></div><div>I don't agree that "basic familiarly with subsystem" is a good criterion. One shouldn't need even basic familiarity with style system to see whether code leaks, introduces refcount thrashing, or copies too much. Using auto tends to make such mistakes much more opaque.</div><div><br></div><div>Raising artificial barriers between subsystems would be really unfortunate, as people tend to work on bugs in many areas.</div><div><br></div><blockquote type="cite"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;">Thoughts?</blockquote></blockquote><div><br></div><div>The latest set of rules proposed by Geoff looks pretty good to me. It would be great to make it a formal requirement. We can always add to it later if things get annoying.</div><br><div apple-content-edited="true"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;">- WBR, Alexey Proskuryakov</span></div></div><div><br></div></body></html>