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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06.11.2013, at 23:17, Jonathan Nieder <jrnieder@xxxxxxxxx> wrote:

> 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.

> 
>> 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.

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]