Subject: Re: [PATCH 11/11] strvec: rename struct fields

From: Junio C Hamano <[email-masked]>
Date: Wed, 29 Jul 2020 11:03:58 -0700

Jeff King <[email-masked]> writes:

>> Using "str" would be consistent with oid_array where the individual
>> component is called "oid" as it is defined this way:
>> 
>> struct oid_array {
>>         struct object_id *oid;
>>         size_t nr;
>>         size_t alloc;
>>         int sorted;
>> };
>
> Yeah, I agree "str" is a reasonable name, and probably better than
> "elem" or "items". I do still like the super-concise "v" better, though.

One problem with names like "str", "string", and "oid" is that it
leads to this stupid pattern:

    struct oid_array *oid;
    oid_to_hex(oid->oid[0], ...);

We know the thing is object name by the pointer variable having the
name oid already---there is no need to repeat we are talking about
oid again with the field name.

So, "str" being consistent with "oid_array" is not necessarily a
plus.

Ultra-concise v[] that stands for value, or e[] that stands for
element, do not share this problem.

One plus about the redundant field name is that it is easier to run

    grep -E -e "([.]|->)oid"

but I do not know how important that is.