lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]




Am 03.09.2018 um 21:06 schrieb Egor Skriptunoff:
On Sun, Sep 2, 2018 at 9:18 PM, Dirk Laurie wrote:
If you have variables x1 and xi, and by accident type xi when you mean x1


Yes, the typo "x1" -> "xi" is easy to make and hard to detect.
As Lorenzo already said, variables naming like "x1, x2, x3, ..., xi, xj" is a bad programming style.
In most use cases (under "good style"), the Levenshtein distance between existing identifiers is rather big.
(the Levenshtein distance is the minimal number of typos required to transform one string into another)
So, the probability of typos accidentally converting one existing identifier into another, is almost zero.

x1 <-> xi is relatively safe, compared with x1 <-> xl, or X0 <-> XO
"ex" "one" <-> "ex" "el", or "EX" "zero" <-> "EX" "OH"

I never use small L or capital O for variable names:
C:    for (i=l; i>O; i++)
Lua; for i=O,l do ... end


--
01iver