Re: is #f a valid index? Marc Nieper-Wißkirchen 30 Jun 2020 09:35 UTC

Am Di., 30. Juni 2020 um 11:18 Uhr schrieb Alex Shinn <xxxxxx@gmail.com>:
>
> 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?

Yes, that's strange and encourages writing code that muddles types.
PHP has been criticized for this type of weak typing.

Apart from that, `string-cursor->index' would be a misnomer. R7RS
renamed the R5RS procedures exact->inexact/inexact->exact to
inexact/exact. By the same reason,
string-cursor->index/index->string-cursor should be named index/cursor
if they are likewise weakly typed.

Finally, the way it is spec'ed in SRFI 130 doesn't allow an
implementation of string cursors by integers that are not necessarily
indices (a cursor could be a byte offset).

Thus, I think there are three good reasons why SRFI 130 should be amended.

Marc