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

Re: [PATCH 1/1] Add a helper to reverse index_pos_to_insert_pos()

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 9, 2019, 12:09 UTC
Message-ID
<xmqqa7aaktm0.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<nycvar.QRO.7.76.6.1910091358360.46@tvgsbejvaqbjf.bet>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 19 quoted lines
> On Wed, 9 Oct 2019, Junio C Hamano wrote:
>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>>
>> > FWIW I actually agree with Junio about the helper, but in hindsight I
>> > could have used a better name (not one that is tied to the "index").
>> > Something like `unsigned_one_complement()`. But of course, that would
>> > say _what_ it does, not _why_.
>>
>> I personally feel that the particular name is on the better side of
>> the borderline.  "st_add3(a, b, c)" says it is about adding three
>> size_t quantities, without saying why it exists and should be used
>> over a+b+c.  Existence of the helper and calling it alone should be
>> a good enough sign that we somehow feel a+b+c is not sufficient [ly
>> safe], so we do not call it st_add3_safe() or st_add3_wo_overflow().
>>
>> Your unsigned-one-complement would fall into the same category, no?
>
> Yes. That's what I meant to say with the "what vs why" argument.

And what I wanted to say was that, even though we encourage use of names that convey _why_, in a case like this, the name that conveys only what without explicitly saying why is probably OK.

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 9 of 11 in “Fallout from azure-pipelines-msvc”
  1. 0/1 Fallout from azure-pipelines-msvcJohannes Schindelin via GitGitGadget, Oct 8, 2019
  2. 1/1 Add a helper to reverse index_pos_to_insert_pos()Johannes Schindelin via GitGitGadget, Oct 8, 2019
  3. Johannes SixtOct 8, 2019
  4. Junio C HamanoOct 9, 2019
  5. Johannes SixtOct 9, 2019
  6. Johannes SchindelinOct 9, 2019
  7. Junio C HamanoOct 9, 2019
  8. Johannes SchindelinOct 9, 2019
  9. Junio C HamanoOct 9, 2019
  10. Johannes SchindelinOct 9, 2019
  11. Johannes SchindelinOct 9, 2019

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.