Hi, Will.  I hope that all is going well for you and your loved ones in this strange time.

A question came up on the SRFI 130 mailing list about the nice test suite that you implemented.  In many places, it makes an assumption that string-cursor->index will, when given #f as an argument, return it.  That doesn't match the spec, though.  (See below and the longer thread in the web archive.)

I've put together a patch to remove this assumption.  Would you mind taking a look to see whether you agree with making this change to the sample implementation?

Thanks.

---------- Forwarded message ---------
From: John Cowan <xxxxxx@ccil.org>
Date: Thu, Jun 25, 2020 at 2:20 PM
Subject: Re: is #f a valid index?
To: Duy Nguyen <xxxxxx@gmail.com>
Cc: <xxxxxx@srfi.schemers.org>


Sorry for the super-long delay in responding: Arthur has pinged me about this one repeatedly.  All the implementations of string-cursor->index simply return the argument unchanged, so (string-cursor->index #f) => #f.  That is a valid result,
since domain errors like this are "is an error" territory and the implementation can do whatever it likes.  But certainly the test should not *rely* on that behavior: it should be rewritten to only call string-cursor->index on legitimate cursors or indices, never on anything else.

Since I didn't write these tests (Will Clinger did, at least according to git blame), I'm not inclined to fix them; the simplest thing might be just to remove that test.


On Wed, Jan 29, 2020 at 7:23 AM Duy Nguyen <xxxxxx@gmail.com> wrote:
srfi-130-test.scm has this code

(or (eqv? #f
          (string-cursor->index "abcdeffffoo"
                                (string-contains "abcdeffffoo" "efffoo")))
    (fail 'string-contains))

where string-contains returns #f. My interpretation of the srfi is
string-cursor->index only lets indexes through besides cursors, so if
it works in this case (by design) then #f has to be a valid index?

The alternative is of course simpler, the test is wrong (because the
reference implementation lets anything through) and
string-cursor->index should not be called here. I tried it out on
chibi, string->cursor->index there does not accept #f either.
--
Duy