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

Re: [PATCH 0/11] renaming argv_array

From
Jeff King <peff@peff.net>
Date
Jul 29, 2020, 16:33 UTC
Message-ID
<20200729163305.GB2320983@coredump.intra.peff.net>
In-Reply-To
<CAP8UFD26J6W50SeQqJiG0y04kcdNzr6RRT7ZeJmrQ2V-QTS3Lg@mail.gmail.com>
On Wed, Jul 29, 2020 at 08:15:54AM +0200, Christian Couder wrote:
Show 15 quoted lines
> On Tue, Jul 28, 2020 at 10:23 PM Jeff King <peff@peff.net> wrote:
> >
> > The argv_array data type has turned out to be useful in our code base,
> > but the name isn't very good. From patch 2 of this series:
> >
> >   The name "argv-array" isn't very good, because it describes what the
> >   data type can be used for (program argument arrays), not what it
> >   actually is (a dynamically-growing string array that maintains a
> >   NULL-terminator invariant).
> 
> I cannot help but notice that you still use "array" when describing
> what it is. You actually use "string array" to describe what it is,
> and at the same time say that the name should describe what it is. So
> I would expect after the above sentence that you would rename it to
> "string_array" or "str_array".

I think one thing that leads me to "vec" is the "v" from "argv", which implies the NULL-terminator (though of course that's _not_ implied by "vector" in other languages). None of the other "array" types have that feature, and it's an important one here.

Show 5 quoted lines
> > "strarray" would work, too, but it's
> > longer and a bit more awkward to say (and don't we all say these things
> > in our mind as we type them?).
> 
> It's longer than "strarray" by 2 characters only.

Yeah, I agree the length between the two is not super important. Mostly I find it harder to read and say. That's obviously subjective, but I do think counts for something.

We use an underscore for "oid_array" (which I think makes sense because it's awkward to concatenate directly a word that starts with a vowel and has multiple syllables). That makes it inconsistent with oidmap and oidset. Likewise, I was hoping for consistency with strbuf here.

Show 6 quoted lines
> Also we still use "array" in "oid_array" which is very similar to
> this. And the implementation is based on the ALLOC_GROW macro which
> uses the REALLOC_ARRAY macro.
> 
> We also use ALLOC_ARRAY, FLEX_ARRAY, CALLOC_ARRAY, COPY_ARRAY and
> MOVE_ARRAY macros.

Those macro names are pretty bulky, but I think it matters a lot less because they're used a lot less. The type name here is prepended to all of the "method" functions like strvec_pushf(), etc.

> So if you don't like the "array" part of the name, are you going to
> also change "oid_array" into "oidvec" and for example "REALLOC_ARRAY"
> into "REALLOC_VEC" or "REALLOC_VECTOR"?

I hadn't planned on it, just because I think the cost of changing versus the benefit is not that high. If I were designing from scratch, I'd definitely consider oidvec (but probably not REALLOC_VEC for the reasons above).

I think the cost of changing away from argv_array _is_ worth it, and once we're doing that, we can choose between the alternatives without paying an extra cost.

> If you want to change only "argv_array" (and not also "oid_array",
> "REALLOC_ARRAY" and perhaps other *_ARRAY macros) into something else,
> then I think it would be better to be consistent with them.

I definitely sympathize with the consistency argument, and I don't think 'str_array" is the end of the world. But I think there are many dimensions of inconsistency already, so without renaming every data structure, we're going to be inconsistent with something. Mostly I just subjectively find strvec easier to read, say, and type, and I don't think the inconsistencies are so glaring that it's a problem.

-Peff
Previous: Eric SunshineNext: René Scharfe
Message 34 of 46 in “renaming argv_array”
  1. 0/11 renaming argv_arrayJeff King, Jul 28, 2020
  2. 01/11 argv-array: use size_t for count and allocJeff King, Jul 28, 2020
  3. 02/11 argv-array: rename to strvecJeff King, Jul 28, 2020
  4. 03/11 strvec: rename files from argv-array to strvecJeff King, Jul 28, 2020
  5. 04/11 quote: rename sq_dequote_to_argv_array to mention strvecJeff King, Jul 28, 2020
  6. 05/11 strvec: convert builtin/ callers away from argv_array nameJeff King, Jul 28, 2020
  7. 06/11 strvec: convert more callers away from argv_array nameJeff King, Jul 28, 2020
  8. 07/11 strvec: convert remaining callers away from argv_array nameJeff King, Jul 28, 2020
  9. 08/11 strvec: fix indentation in renamed callsJeff King, Jul 28, 2020
  10. Jacob KellerJul 28, 2020
  11. Junio C HamanoJul 28, 2020
  12. 09/11 strvec: update documention to avoid argv_arrayJeff King, Jul 28, 2020
  13. 10/11 strvec: drop argv_array compatibility layerJeff King, Jul 28, 2020
  14. Junio C HamanoJul 28, 2020
  15. Jeff KingJul 29, 2020
  16. Jeff KingJul 29, 2020
  17. Jeff KingJul 29, 2020
  18. Junio C HamanoJul 29, 2020
  19. Derrick StoleeJul 29, 2020
  20. Junio C HamanoJul 29, 2020
  21. Jeff KingJul 29, 2020
  22. 11/11 strvec: rename struct fieldsJeff King, Jul 28, 2020
  23. Junio C HamanoJul 28, 2020
  24. Junio C HamanoJul 28, 2020
  25. Christian CouderJul 29, 2020
  26. Jeff KingJul 29, 2020
  27. Junio C HamanoJul 29, 2020
  28. Jeff KingJul 28, 2020
  29. Jacob KellerJul 28, 2020
  30. Jeff KingJul 29, 2020
  31. Christian CouderJul 29, 2020
  32. Christian CouderJul 29, 2020
  33. Eric SunshineJul 29, 2020
  34. Jeff KingJul 29, 2020
  35. René ScharfeAug 11, 2020
  36. Taylor BlauAug 11, 2020
  37. Junio C HamanoAug 11, 2020
  38. Jacob KellerAug 11, 2020
  39. Junio C HamanoAug 11, 2020
  40. Johannes SchindelinAug 12, 2020
  41. Jeff KingAug 12, 2020
  42. Jeff KingAug 12, 2020
  43. René ScharfeAug 12, 2020
  44. Jeff KingAug 12, 2020
  45. René ScharfeAug 12, 2020
  46. Jeff KingAug 12, 2020

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.