Nick, thanks for pushing to get -Wshadow turned on. I agree it should be.
Nicholas Nethercote wrote:
On Sun, Sep 23, 2012 at 10:14 PM, Nicholas Nethercote
<[email protected]> wrote:
On Sun, Sep 23, 2012 at 9:48 PM, David Anderson<[email protected]> wrote:
I prefer suffixing _. Under ion/* this has been required style for all
private member variables. (Anywhere not doing it is probably old code.)
What decoration do you suggest to avoid conflicts for parameters?
Terrence said they've been using |fooArg| for parameters that are
immediately rooted as |foo|. So that's a possibility for avoiding
parameter conflicts.
It's getting heavier by the shifted character, though. At least fooArg
preserves foo's spelling (however camelCased or lowercased) as David
pointed out.
The functions that take unrooted parameters and root them should be few
and in jsapi.cpp, mostly -- right? Otherwise we are probably re-rooting
unnecessarily.
So, the straw-man minimal changes required to enable -Wshadow are
demonstrated in this example:
class X
{
int x_;
X(int xArg) : x_(xArg) { }
int x() { return x_; }
void setX(int xArg) { x_ = xArg; }
void foo() {
int x0 = x();
// ... use x0 ...
};
};
Rules:
- members are decorated with a '_' suffix if necessary
- parameters are decorated with a 'Arg' suffix if necessary
- local variables are decorated with a '0' suffix if necessary (other
suggestions welcome... AFAIK Gecko doesn't have a standard way of
handling this case, but it does come up occasionally in practice)
BTW, if the above example seems unrealistic, it's not; imagine |X| is
|Vector| and |x| is |length|.
This is a bit contrived -- len is a better local name than length0 for
capturing the return value of a this-relative length() method call, anyway.
How about we avoid the x0 convention, enable -Wshadow, and see what happens?
/be
_______________________________________________
dev-tech-js-engine-internals mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-internals