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

Re: [PATCH 2/5] roaring.[ch]: apply Git specific changes to the roaring API

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 21, 2022, 16:58 UTC
Message-ID
<xmqq5yhg64vn.fsf@gitster.g>
In-Reply-To
<990f84f9-fdd9-0d0a-4fc0-d0dbd19ee5a9@github.com>
Derrick Stolee <derrickstolee@github.com> writes:
Show 10 quoted lines
>> Hmph.... could "a typedef can become a place to give definitive
>> documentation for the class of callback functions" be a good reason
>> why we would want one?  I dunno.
>> 
>> In the posted patch, readers cannot tell what kind of three
>> parameters they are supposed to give to write_fn().
>
> This is exactly my reasoning. Having a clear definition gives us an
> opportunity to document what each parameter is for, even if it is
> just a variable name.
Yeah, I completely agree with you on that line of reasoning.
> In the unlikely event that we needed to modify this callback
> signature, changing it in one place makes it clear that we cover
> all connected uses instead of tracking all of these anonymous
> functions across multiple methods.

Well, the compiler will help flagging a caller that forgot to convert, even if there is no typedef.

The parameter list may not have to be updated for a function that takes a callback function of this type as its parameter if you did not use a typedef, but where it in turn makes a call to that callback function, the compiler will notice the argument mismatch, which you have to adjust to the new calling convention anyway.

What is somewhat sad is that even with typedef, the implementation of a callback function cannot use the type, but the longhand that underlies the typedef, to define it, but that is not something we can fix, or are interested in fixing ;-).

Thanks.
Previous: Abhradeep ChakrabortyNext: Abhradeep Chakraborty
Message 9 of 25 in “[RFC] introduce Roaring bitmaps to Git”
  1. 0/5 [RFC] introduce Roaring bitmaps to GitAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  2. 1/5 reachability-bitmaps: add CRoaring library to GitAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  3. 4/5 roaring: introduce a new config option for roaring bitmapsAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  4. 2/5 roaring.[ch]: apply Git specific changes to the roaring APIAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  5. Derrick StoleeSep 19, 2022
  6. Junio C HamanoSep 19, 2022
  7. Derrick StoleeSep 20, 2022
  8. Abhradeep ChakrabortySep 20, 2022
  9. Junio C HamanoSep 21, 2022
  10. Abhradeep ChakrabortySep 20, 2022
  11. 3/5 roaring: teach Git to write roaring bitmapsAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  12. Junio C HamanoSep 30, 2022
  13. Abhradeep ChakrabortySep 30, 2022
  14. Abhradeep ChakrabortyOct 30, 2022
  15. Derrick StoleeOct 30, 2022
  16. Abhradeep ChakrabortyOct 31, 2022
  17. Junio C HamanoOct 31, 2022
  18. C99 -> C11 or C17? (was: [PATCH 3/5] roaring: teach Git to write roaring bitmaps)Ævar Arnfjörð Bjarmason, Oct 31, 2022
  19. rsbecker@nexbridge.comOct 31, 2022
  20. Abhradeep ChakrabortyNov 1, 2022
  21. 5/5 roaring: teach Git to read roaring bitmapsAbhradeep Chakraborty via GitGitGadget, Sep 19, 2022
  22. Derrick StoleeSep 19, 2022
  23. Abhradeep ChakrabortySep 20, 2022
  24. Taylor BlauSep 20, 2022
  25. Abhradeep ChakrabortySep 21, 2022

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.