On Wed, Oct 1, 2014 at 4:42 PM, L. David Baron <dba...@dbaron.org> wrote:

> On Wednesday 2014-10-01 16:24 -0700, Eric Rescorla wrote:
> > Obviously, if you have some argument that auto is bad programming
> practice
> > or a hazard and should thus be forbidden, that's something you could make
> > and
> > see if people generally agree...
>
> I think there are cases where |auto| makes code substantially less
> readable, and cases where it's fine.  I don't think I have enough
> experience reading code using |auto| to say exactly what's in which
> set, but I have mandated less use of |auto| in code reviews.
>
> Some of it is simple readability; there are cases where seeing the
> type of a variable allows its name to be simpler while preserving
> the same level of readability, and if we're going to hide the type,
> I'd want it to have a more complex name to make the code obvious.
>
> But I'm also worried about use of auto leading people to stop using
> const or & where they should be (particularly where |auto| instead
> of |const auto&| leads to unnecessary expensive copies).  (And I
> think knowing whether I want |auto| or |const auto&| requires
> knowing the type, which makes the feature less valuable to me.)
>
> I'm fine with just enforcing reasonable judgment in code reviews,
> although I suspect some people would be bothered by having code
> reviewers enforce style rules that aren't written down.
>

Yes this all seems reasonable. FWIW, here's the Google guidance.

http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#auto

-Ekr
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to