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. -David -- 𝄞 L. David Baron http://dbaron.org/ 𝄂 𝄢 Mozilla https://www.mozilla.org/ 𝄂 Before I built a wall I'd ask to know What I was walling in or walling out, And to whom I was like to give offense. - Robert Frost, Mending Wall (1914)
signature.asc
Description: Digital signature
_______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform