Subject: Re: [PATCH v2 1/2] string-list: Add string_list initializer helper functions

From: Junio C Hamano <[email-masked]>
Date: Tue, 17 Jun 2014 15:10:26 -0700

Tanay Abhra <[email-masked]> writes:

> On 06/16/2014 03:59 PM, Junio C Hamano wrote:
>> Tanay Abhra <[email-masked]> writes:
>> 
>>> When a compound construct like a string_list within another
>>> struct is used, the default initializer macros are useless.
>>> For such cases add helper functions for string_list
>>> initialization for both DUP and NODUP modes.
>>>
>>> Signed-off-by: Tanay Abhra <[email-masked]>
>>> ---
>> 
>> 
>> Sorry, but I do not understand the above "useless".  Do you mean to
>> say that xyzzy below cannot be initialized that way?
>>  ...
> I was actually explaining for cases like below,
> ...
> +		string_list_init_dup(&e->value_list);

If that is what you wanted to refer to, I would have to say
"useless" is placing a stress on a wrong place.  (I do not see
anything wrong with your new code; it was just the way it was
explained in the proposed log message was misleading).

Structure initialisers are not something you can assign to a
variable anyway, and calling them "useless" is like complaining how
unwieldty hammers are on screws.  "Hammers are useless on screws"
may not be technically wrong per-se, but the readers won't be helped
by hearing it very much.

Instead, you would want to explain what your new invention, a
screwdriver, is and how it is intended to be used.

We of course have precedences for this kind of thing.  STRBUF_INIT
is for definition-time initialisation and strbuf_init() is to
initialise an uninitialised piece of memory to be used as a strbuf.

I tend to think it was a long-time misdesign of string-list API to
have the STRING_LIST_INIT* definition-time initialisers without
having runtime string_list_init*() initialisers, and it is a good
idea to add them to complete the API.

If I were writing the log message for this, I would just say:

	The string-list API has STRING_LIST_INIT_* macros to be used
	to define variables with initialisers, but lacks functions
	to initialise an uninitialised piece of memory to be used as
	a string-list at the run-time.

        Introduce string_list_init_{dup,nodup}() functions for that.

or something.