lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <mar...@rectangular.com>
Subject Re: [lucy-dev] Clownfish String API
Date Thu, 22 Oct 2015 21:57:32 GMT
On Sun, Oct 18, 2015 at 5:01 AM, Nick Wellnhofer <wellnhofer@aevum.de> wrote:
> On 15/10/2015 21:21, Marvin Humphrey wrote:

>> *   Remove `new_from_char`.
>
>
> -0.5
>
>> *   Remove `BaseX_To_I64`, optionally adding its functionality to
>>      StringHelper.
>
>
> +0

I don't feel that strongly about either of these, so I'm amenable to your
plan.

>>> StringIterator
>>>
>>> - Rename StrIter_substring to Str_new_from_iter?
>>
>>
>> Hmm.  I see where you're going with that, but new_from_iter doesn't
>> communicate that there must be a single backing String for the two
>> StringIterator arguments.  Maybe `StrIter_crop`?
>
> I'm also OK with either StrIter_substring ot StrIter_crop. I only thought it
> might be clearer to make this function a constructor of the String class.

Then how about `Str_crop`?  I think that would be OK because it correctly
implies that we're cropping a single source String.

>>> - Make `Starts_With`, `Ends_With` skip over strings?
>>>    I think this better matches current usage patterns.
>>
>>
>> Somehow I don't understand what you mean.
>
>
> I mean that `Starts_With` should be named something like `Advance_If_Match`
> and make the iterator move past the prefix if it matches. Currently, most
> code that calls StrIter_Start_With looks like
>
>     if (StrIter_Starts_With(iter, prefix)) {
>         StrIter_Advance(iter, prefix_len);
>         ...
>     }
>
> This could be replaced with a simpler and more efficient
>
>     if (StrIter_Advance_If_Match(iter, prefix)) {
>         ...
>     }

How about `Skip_Match`?

    if (!StrIter_Skip_Match(iter, prefix)) {
        return 0;
    }

>>> - Find better names for `Skip_{Next|Prev}_Whitespace`?
>>
>> `Advance_Whitespace` and `Recede_Whitespace`?
>
> As a non-native speaker, I'm not really sure.

I think `Skip_Whitespace` is the best option for forward skipping.  I can't
think of a good option for moving backwards past any whitespace before the
current iterator position.  It's not a common operation, though, and I can
live with a suboptimal name.  `Skip_Prev_Whitespace` might be the clearest,
since it can be contrasted with `Skip_Whitespace` -- and it's less
gramatically awkward than `Recede_Whitespace`.

Marvin Humphrey

Mime
View raw message