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

Re: [PATCH v3 2/2] Rename suffixcmp() to has_suffix() and invert its result

From
Max Horn <max@quendi.de>
Date
Nov 6, 2013, 22:56 UTC
Message-ID
<61456C34-834F-4E7B-89D2-9DB45690C9ED@quendi.de>
In-Reply-To
<20131106221735.GB10302@google.com>
On 06.11.2013, at 23:17, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 9 quoted lines
> Hi,
> 
> Christian Couder wrote:
> 
>> Now has_suffix() returns 1 when the suffix is present and 0 otherwise.
> 
> Ok.  My only worry is that the function is less discoverable since
> its name is so different from prefixcmp(), which might cause someone
> to invent yet another postfixcmp.
Well, that can always happen, no matter what, can't it?
Though personally I wouldn't mind if there was an has_prefix instead or in parallel to prefixcmp.
Show 7 quoted lines
> 
>> The old name followed the pattern anything-cmp(), which suggests
>> a general comparison function suitable for e.g. sorting objects.
>> But this was not the case for suffixcmp().
> 
> It's not clear to me that prefixcmp() is usable for sorting objects,
> either.  Shouldn't it get the same treatment?
Well, unlike suffixcmp, it is transitive, so it could be used for sorting. Whether doing that would be sensible is another question, though :-).
For clarity, it might indeed be better to also change prefixcmp to has_prefix(), and if some code pops up in the future that needs something like the current prefixcmp, it can still be added back.
Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 of 7 in “Rename suffixcmp() to has_suffix() and invert its result”
  1. 2/2 Rename suffixcmp() to has_suffix() and invert its resultChristian Couder, Nov 5, 2013
  2. Jonathan NiederNov 6, 2013
  3. Max HornNov 6, 2013
  4. Jonathan NiederNov 6, 2013
  5. Max HornNov 6, 2013
  6. Junio C HamanoNov 7, 2013
  7. Christian CouderNov 7, 2013

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.