<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 <<a href="mailto:bfulgham@apple.com">bfulgham@apple.com</a>> 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 <<a href="mailto:ggaren@apple.com">ggaren@apple.com</a>> wrote:<br><br><blockquote type="cite"><blockquote type="cite">+ auto newRenderer = textNode.createTextRenderer(style);<br>+ ASSERT(newRenderer);<br><br>….<br><br>+ parentRenderer->addChild(newRenderer.leakPtr(), nextRenderer);<br></blockquote><br>I think this use of “auto” is net harmful.<span class="Apple-converted-space"> </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< RenderText>”. 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. 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. For example, this treasure, from display-profiler-output:</div><div dir="auto"><br></div><div dir="auto"><div dir="auto"> compilation.descriptions.each {</div><div dir="auto"> | description |</div><div dir="auto"> if description.origin.index {</div><div dir="auto"> | myBytecode |</div><div dir="auto"> bytecodes == myBytecode.bytecodes</div><div dir="auto"> }</div><div dir="auto"> myOrigins << description.origin</div><div dir="auto"> end</div><div dir="auto"> }</div><div><br></div><div>It's true that "compilation" points to a Compilation. But what does descriptions point to? It turns out that it's an array of CompiledBytecode objects. This is a relevant piece of information because it tells you what kinds of information each element in the array contains. You can figure this out if you search for all of the places that the descriptions array gets populated. But, there is no way to see this from looking at the declaration of "compilation" or "descriptions". 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 < compilation->descriptions().size(); ++i) {</div><div> CompiledBytecode& description = compilation->descriptions()[i];</div><div> ... // 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. 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>