[LLVMdev] RFC: variable names (original) (raw)

Robinson, Paul Paul_Robinson at playstation.sony.com
Mon Oct 13 17:41:28 PDT 2014


struct MyClass { static int x; int y;

void MyFunction(MyClass a, MyClass b) { int c; std::sort(......, [] { std::ptrdifft d = ...; ++c; // ... f(a.x); g(x); h(y); }); } }; Between arguments, lambda captures, non-static and static locals, I have no idea how to usefully distinguish between x, y, a, b, c and d here. I don't think it is meaningful to try. They are all variables.

You're too good a programmer. :-) If you'd shot yourself in the foot more often you might appreciate a convention that distinguishes between a transient local variable and one that is the same entity used by twelve other methods in the class.

In this example I'd argue that x and y are meaningfully different things than a, b, c, and d. And, that if I see a lambda body that says ++c; f(a.x_); g(x_); h(y_); it's useful to know just by looking at it that c belongs to the function and x_ and y_ belong to the class instance. --paulr



More information about the llvm-dev mailing list