[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Prefer very easily distinguished names
From: |
Vadim Zeitlin |
Subject: |
Re: [lmi] Prefer very easily distinguished names |
Date: |
Mon, 4 Jun 2018 17:55:14 +0200 |
On Fri, 1 Jun 2018 22:54:26 +0000 Greg Chicares <address@hidden> wrote:
GC> On 2018-05-27 15:30, Vadim Zeitlin wrote:
GC> [...]
GC> > Sorry, I hadn't realized it but apparently we just have completely
GC> > different mental models for reading. For me it's completely immaterial
that
GC> > "col" is contained in "col_width"
GC>
GC> Differences in visual acuity are also important.
OK, this is reasonable.
GC> Recently I read a post by a well-known C++ expert who dislikes
GC> suffixing data members with an underscore because he finds it hard to
GC> distinguish col from col_.
It's true that e.g. "this->col" convention is more noticeable and I did
wonder in the past why you didn't use it. I don't like it personally
because it seems too verbose and also like a Pythonism to me, but at least
it's logically defensible.
GC> > GC> when I saw
GC> > GC> for(auto const& line : lines)
GC> > GC> my heart sank--I thought I had overlooked a glaring defect.
GC> >
GC> > I honestly absolutely no idea what this defect could be :-(
GC>
GC> I see two shapes that look almost indistinguishable. The last two
GC> characters in the plural name both look like 'ɵ' to me; doubling
GC> that letter doesn't make it look very different from the singular.
I can understand this, but my preferred solution would be to use more
distinct variable names, not less expressive ones.
GC> > I've now found my new absolutely least favourite (and by far)
GC> > lmi style rule :-(
GC>
GC> Consider it repealed.
Please accept my heartfelt thanks, this is a huge relief for me. What do
you think of amending the style guide in this way:
---------------------------------- >8 --------------------------------------
diff --git a/vz/Style-guide.md b/vz/Style-guide.md
index fac71a51f..bb41ad271 100644
--- a/vz/Style-guide.md
+++ b/vz/Style-guide.md
@@ -140,8 +140,10 @@ code if possible.
### Standard variable names
-Use `z` for local variables whose names are unimportant (similar to `_` in some
+* Use `z` for local variables whose names are unimportant (similar to `_` in
some
other languages).
+* Use `i` for the loop variable (and then `j`, `k` for nested loops) by
+default, i.e. if there are no better and more specific name candidates.
Other
---------------------------------- >8 --------------------------------------
?
GC> But if it had said
GC> if(oall[field] != cell[field])
GC> then I'd find the LHS and RHS indistinguishable.
It's not going to completely solve the problem, but I find it helpful to
put the cursor on an identifier I'm interested in and press "*" (in Vim, of
course, but where else would I be). With 'hls[earch]' option on, this
allows to immediately see all the occurrences of this identifier on the
screen and, as a side effect, makes it distinct from all the other ones
(and if "*" takes you too far away, it's just a matter of pressing "''" to
get back).
Regards,
VZ