From: Junio C Hamano <gitster@pobox•com>
To: Tanay Abhra <tanayabh@gmail•com>
Cc: git@vger•kernel.org, Ramkumar Ramachandra <artagnon@gmail•com>,
Matthieu Moy <Matthieu.Moy@grenoble-inp•fr>,
Eric Sunshine <sunshine@sunshineco•com>
Subject: Re: [PATCH v2 1/2] string-list: Add string_list initializer helper functions
Date: Tue, 17 Jun 2014 15:10:26 -0700 [thread overview]
Message-ID: <xmqqr42njigd.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <53A09192.2030008@gmail.com> (Tanay Abhra's message of "Tue, 17 Jun 2014 12:05:54 -0700")
Tanay Abhra <tanayabh@gmail•com> writes:
> 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.
next prev parent reply other threads:[~2014-06-17 22:10 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-16 8:27 [PATCH v2 0/2] Git config cache & special querying api utilizing the cache Tanay Abhra
2014-06-16 8:27 ` [PATCH v2 1/2] string-list: Add string_list initializer helper functions Tanay Abhra
2014-06-16 22:59 ` Junio C Hamano
2014-06-17 19:05 ` Tanay Abhra
2014-06-17 22:10 ` Junio C Hamano [this message]
2014-06-16 8:27 ` [PATCH v2 2/2] config: Add hashtable for config parsing & retrieval Tanay Abhra
2014-06-16 17:11 ` Matthieu Moy
2014-06-16 17:28 ` Tanay Abhra
2014-06-16 17:35 ` Matthieu Moy
2014-06-17 5:34 ` Jeff King
2014-06-17 5:46 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqr42njigd.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=Matthieu.Moy@grenoble-inp$(echo .)fr \
--cc=artagnon@gmail$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=sunshine@sunshineco$(echo .)com \
--cc=tanayabh@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox