[webkit-dev] When to use "auto"? (I usually consider it harmful)

Geoffrey Garen ggaren at apple.com
Thu Jan 2 14:28:56 PST 2014


> What do you think about these examples?
> 
>     auto failureCallback = [promiseWrapper]() mutable {
>         promiseWrapper.reject(nullptr);
>     };

Here I think auto is good because the type is disgusting to write out by hand, and because the type is clearly visible on the right hand side of the expression.

>     auto iter = m_nameToIdentifierMap.find(name.isolatedCopy());
>     if (iter == m_nameToIdentifierMap.end())
>         return false;

Here I think auto is good because it likely meets the "disgusting templated iterator type” clause — even though it’s not in a loop.

Geoff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20140102/5802fbfa/attachment.html>


More information about the webkit-dev mailing list