Hi Alejandro,

> > [CCing sc22wg14]
> 
> [I've removed WG14, as I think planning outside of their sight can be
> more productive.]

That's OK. I just wanted to make the committee aware that good naming is
important and that the names in the current proposal are not good naming,
IMO.

> Since gnulib would be the first implementor, and my proposal won't be
> voted until February or March, gnulib has the chance to influence on the
> name.
> 
> If you implement them as XXXprefix() and XXXsuffix(), I'll change my
> proposal, due to prior art.
> 
> The committee, a priory, would refuse such common names, due to fears of
> breaking much existing code.  However, if major existing libc
> implementations use them, it might turn the votes.
> 
> If you start with strprefix()/suffix(), and then glibc may follow, we
> have two of the major libc implementations.  musl and Bionic would
> probably follow for compatibility.
> 
> But this must come from implementations.  The committee will not help.

Thanks for the insight. (I don't have much experience with WG14.)

The major reason that speaks for the name 'str_startswith', as used
in Gnulib, is:
  - The term starts-with is already used for this purpose in
    10 out of 15 programming languages. Find attached a summary from
    the prior knowledge summarization engine.
  - The prefix 'str' shows that it's for 'char *' strings and allows
    a similar function with prefix 'wcs' for 'wchar_t *' wide strings.

Therefore, I think we should stay with that for Gnulib. No 'strprefix'
or such.

Then, let's look for a readable and pronounceable name for the variant
that returns a pointer.

  - I tried thinking in terms of parsing, i.e. "str_parse_prefix",
    but what about the one with suffix then? "str_backwardparse_suffix"?
    Backward parsing is rarely seen in code.

  - How about the names 'str_prefix_end' and 'str_suffix_start'?
    It's descriptive.
    It's pronounceable.
    The names imply that they return a pointer.
    The names are not very long, compared to what we already find in ISO C:

      str_prefix_end
      str_suffix_start
      fegetexceptflag
      fe_dec_getround
      fmaximum_mag_num
      decodebind128
      atomic_compare_exchange
      atomic_flag_test_and_set
      atomic_flag_test_and_set_explicit
      stdc_first_leading_zero_ull
      memset_explicit

    They are not used at all [1][2] in existing code, so not a hindrance
    for WG14.

Bruno

[1] https://codesearch.debian.net/search?q=str_prefix_end&literal=1
[2] https://codesearch.debian.net/search?q=str_suffix_start&literal=1

Attachment: startswith.odt
Description: application/vnd.oasis.opendocument.text

Reply via email to