On Monday 2015-07-06 23:25 -0400, Hubert Figuière wrote: > On 06/07/15 11:12 PM, Jeff Gilbert wrote: > > I propose that we stop recommending the universal use of an 'a' prefix for > > arguments to functions in C and C++. If the prefix helps with > > disambiguation, that's fine. However, use of this prefix should not be > > prescribed in general. > > > > `aFoo` does not provide any additional safety that I know of.[1] As a > > superfluous prefix, it adds visual noise, reducing immediate readability of > > all function declarations and subsequent usage of the variables within the > > function definition. > > [...] > > > I propose we strike the `aFoo` recommendation from the Mozilla style guide. > > I agree with this. > > However, if we proceed to remove this from the style guide, will we run > a pass at removing the 'a' prefix or will we just let them be and have > individual code change eventually clean them up?
It seems likely to be hard to automate, since there will be a significant number of places where the obvious substitution (remove "a" and lowercase the letter following it) yields name conflicts. And I'm not sure how I'd feel about having inconsistent style for years, if we can't automate it. > Do we have -Wshadow (or equivalent) enabled across the code base and > insurance that the warnings get dealt with? No, we don't. I wish we did. I think it's among the more useful warnings at finding real problems, but the JS engine and some other pieces of code use a style that frequently uses shadowing. (It was on many years ago, but we turned it off due to a gcc bug (see bug 75621), C-only (not C++), that gave bogus shadowing warnings for all variables with the same names as certain global functions (|index|, etc.), that affected the JS engine in C. When the JS engine switched from C to C++, I failed to remember to turn it back on quickly, and then the JS engine, and later some other big chunks of imported code (e.g., ipc), ended up using a style that's very noisy with -Wshadow.) Nick Nethercote did a good bit of work to try to get it on, but gave up (see bug 800659). I have -Wshadow turned on in my own builds, and have continuously since we turned it off in general, and it's extremely noisy, but also spits out a number of things that point to confusing code. The noise basically means that compiler output as a whole is useless for me (errors are very difficult to find, and I never look at warnings at all), but I haven't been able to bring myself to give up completely on it. (I effectively have all warnings disabled in the hope that what I'm doing might one day help get -Wshadow turned back on, even though I never actually do anything.) It's possible that clang's -Wshadow might be easier to turn on that gcc's, though (see https://bugzilla.mozilla.org/show_bug.cgi?id=800659#c11 ). -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