<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On Jan 2, 2014, at 1:59 PM, Brent Fulgham &lt;<a href="mailto:bfulgham@apple.com">bfulgham@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hi,<br><br>On Jan 2, 2014, at 1:12 PM, Geoffrey Garen &lt;<a href="mailto:ggaren@apple.com">ggaren@apple.com</a>&gt; wrote:<br><br><blockquote type="cite"><blockquote type="cite">+ &nbsp;&nbsp;&nbsp;auto newRenderer = textNode.createTextRenderer(style);<br>+ &nbsp;&nbsp;&nbsp;ASSERT(newRenderer);<br><br>….<br><br>+ &nbsp;&nbsp;&nbsp;parentRenderer-&gt;addChild(newRenderer.leakPtr(), nextRenderer);<br></blockquote><br>I think this use of “auto” is net harmful.<span class="Apple-converted-space">&nbsp;</span><br></blockquote><br>I disagree. I think the use of auto is an improvement, because it makes it less likely that we have something like the following:<br><br>int wrong = something.get64BitInt(); // potential truncation<br><br>There are plenty of cases where we change the signature of functions from one type to another, sometimes promoting sizes. I haven’t seen us do a very consistent job of combing through sources to make sure all receiving variables are properly sized.<br><br>When we don’t use ‘auto’, we run the risk of assigning to variables that the compiler “makes work” by casting. We only know this is happening when the compiler generates a warning (and we look for that warning).<br><br><blockquote type="cite">I think the downsides outweigh the upsides here because reading code is more common than writing code, and because it’s not *that* much typing to write out "RenderPtr&lt; RenderText&gt;”. In this particular code, I think it’s especially bad to disguise the type of a pointer in the render tree, since we’re in the middle of a transition to a new type of pointer, and so it’s important to know if you’re looking at code that does the new thing or the old thing.<br></blockquote><br>Don’t we have this same problem with all of our JavaScript, Python, and Ruby code? We don’t have type specifications in those languages, but we manage to build large software with them as well.<br></div></blockquote><div dir="auto"><br></div><div dir="auto">I can comment about the Ruby code. &nbsp;It's often hard to make sense of that code because you don't have variable types to give you hints about what you're looking at. &nbsp;For example, this treasure, from display-profiler-output:</div><div dir="auto"><br></div><div dir="auto"><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; compilation.descriptions.each {</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | description |</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if description.origin.index {</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; | myBytecode |</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bytecodes == myBytecode.bytecodes</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; myOrigins &lt;&lt; description.origin</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end</div><div dir="auto">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</div><div><br></div><div>It's true that "compilation" points to a Compilation. &nbsp;But what does descriptions point to? &nbsp;It turns out that it's an array of CompiledBytecode objects. &nbsp;This is a relevant piece of information because it tells you what kinds of information each element in the array contains. &nbsp;You can figure this out if you search for all of the places that the descriptions array gets populated. &nbsp;But, there is no way to see this from looking at the declaration of "compilation" or "descriptions". &nbsp;In the C++ code we would write prior to C++11, we would have likely done this as follows:</div><div><br></div><div>for (unsigned i = 0; i &lt; compilation-&gt;descriptions().size(); ++i) {</div><div>&nbsp; &nbsp; CompiledBytecode&amp; description = compilation-&gt;descriptions()[i];</div><div>&nbsp; &nbsp; ... // more stuff</div><div>}</div><div><br></div><div>I find this kind of thing easier to understand, when I have to return to such code after possibly a year, or more, of looking at it. &nbsp;It's code like this that makes me think that 'auto'-everywhere is net harmful.</div><div><br></div><div>-Filip</div><div><br></div></div><br><blockquote type="cite"><div style="font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>-Brent<br>_______________________________________________<br>webkit-dev mailing list<br><a href="mailto:webkit-dev@lists.webkit.org">webkit-dev@lists.webkit.org</a><br><a href="https://lists.webkit.org/mailman/listinfo/webkit-dev">https://lists.webkit.org/mailman/listinfo/webkit-dev</a></div></blockquote></div><br></body></html>