[libvirt PATCH 4/4] docs: coding-style: One variable declaration per line

Ján Tomko jtomko at redhat.com
Fri Jan 14 20:29:35 UTC 2022


On a Friday in 2022, Laine Stump wrote:
>Since it's Friday and we're talking about personal preferences - I 
>personally dislike the use of i and j (and anything else with a single 
>letter) as variable names, because it makes using a text search for 
>occurences pointless. Sure, longer variable names could also be a 
>substring of something else, and any variable could be re-used 
>elsewhere, but even then a search is mildly usable.

Well, you need to search for the word i instead of the letter i.

grep has the '-w' switch for that, or you can specify some boundaries:
    \bi\b
    \<i\>

vim searches for the word under the cursor with '*' by default

Surely other search tools have some equivalent.

>
>(On the other hand, sometimes a loop is just a loop and it takes too 
>much brain capacity to think of a meaningful name for the index. I 
>used to work with someone who always used "ii" and "jj" for generic 
>loop indexes because they were then easy to search for with few false 
>positives (well - "ascii", "skiing", and a surprisingly high number of 
>other more obscure words, but still...) , and I internalized that 
>practice myself. After having libvirt patches with that rejected a 
>couple times, I unlearned and conformed to the hive :-))

II thank you.

JJano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20220114/d62a313a/attachment-0001.sig>


More information about the libvir-list mailing list