Re: is #f a valid index? Duy Nguyen 30 Jun 2020 09:24 UTC

On Tue, Jun 30, 2020 at 4:18 PM Alex Shinn <xxxxxx@gmail.com> wrote:
>
> On Tue, Jun 30, 2020 at 5:59 PM Duy Nguyen <xxxxxx@gmail.com> wrote:
>>
>>
>> I think chibi does not follow the srfi here. The document for
>> string-cursor->index says " If the argument is already an
>> index/cursor, it is returned unchanged. ". So chibi should accept "1"
>> and return it. But it throws an error instead.
>
>
> Yes, I missed that.  It seems strange.  What's next, char->integer
> should return its argument if passed an integer?

I didn't write the srfi. But I guess we're not going that far.
Accepting both indexes and cursors are just to make conversions
between them easier.

I do find this useful in the functions that take both indexes and
cursors. When I need a cursor, I just run the input through
string-index->cursor and I get a cursor. The alternative is check if
it's an index first, then convert, which works but more code.
--
Duy