git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2014, 22:10 UTC
Message-ID
<xmqqr42njigd.fsf@gitster.dls.corp.google.com>
In-Reply-To
<53A09192.2030008@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
Show 18 quoted lines
> On 06/16/2014 03:59 PM, Junio C Hamano wrote:
>> Tanay Abhra <tanayabh@gmail.com> 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 <tanayabh@gmail.com>
>>> ---
>> 
>> 
>> 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.
Previous: Tanay AbhraNext: Tanay Abhra
Message 5 of 11 in “Git config cache & special querying api utilizing the cache”
  1. 0/2 Git config cache & special querying api utilizing the cacheTanay Abhra, Jun 16, 2014
  2. 1/2 string-list: Add string_list initializer helper functionsTanay Abhra, Jun 16, 2014
  3. Junio C HamanoJun 16, 2014
  4. Tanay AbhraJun 17, 2014
  5. Junio C HamanoJun 17, 2014
  6. 2/2 config: Add hashtable for config parsing & retrievalTanay Abhra, Jun 16, 2014
  7. Matthieu MoyJun 16, 2014
  8. Tanay AbhraJun 16, 2014
  9. Matthieu MoyJun 16, 2014
  10. Jeff KingJun 17, 2014
  11. Jeff KingJun 17, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.