From: Junio C Hamano <gitster@pobox.com>
To: Linus Arver <linusa@google.com>
Cc: Jeff King <peff@peff.net>,
Linus Arver via GitGitGadget <gitgitgadget@gmail.com>,
git@vger.kernel.org
Subject: Re: [PATCH] strvec: use correct member name in comments
Date: Fri, 12 Jan 2024 13:47:47 -0800 [thread overview]
Message-ID: <xmqqjzoe8br0.fsf@gitster.g> (raw)
In-Reply-To: <owlyo7dqig1w.fsf@fine.c.googlers.com> (Linus Arver's message of "Fri, 12 Jan 2024 10:04:43 -0800")
Linus Arver <linusa@google.com> writes:
> Side note: should we start naming the parameters in strvec.h? I would
> think that it wouldn't hurt at this point (as the API is pretty stable).
> If you think that's worth it, I could reroll to include that in this
> series (and also improve my commit message for this patch).
I am not sure if it adds more value to outweigh the cost of
churning. When the meaning of the parameters are obvious only by
looking at their types, a prototype without parameter names is
easier to maintain, by allowing the parameters to be renamed only
once in the implementation. When the meaning of parameters are not
obvious from their types, we do want them to be named so that you
only have to refer to the header files to know the argument order.
"void *calloc(size_t, size_t)" would not tell us if we should pass
the size of individual element or the number of elements first, and
writing "void *calloc(size_t nmemb, size_t size)" to make it more
obvious is a good idea.
On the other hand, "void *realloc(void *, size_t)" is sufficient to
tell us that we are passing a pointer as the first parameter and the
desired size as the second parameter, without them having any name.
Are there functions declared in strvec.h you have in mind that their
parameters are confusing and hard to guess what they mean?
Thanks.
next prev parent reply other threads:[~2024-01-12 21:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 7:06 [PATCH] strvec: use correct member name in comments Linus Arver via GitGitGadget
2024-01-12 7:41 ` Jeff King
2024-01-12 18:04 ` Linus Arver
2024-01-12 21:47 ` Junio C Hamano [this message]
2024-01-13 0:37 ` Linus Arver
2024-01-13 7:31 ` Jeff King
2024-01-14 18:20 ` Linus Arver
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=xmqqjzoe8br0.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=linusa@google.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).