chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] Bug in SRFI 13 string-skip-right (was: fix for str


From: Alex Shinn
Subject: Re: [Chicken-hackers] Bug in SRFI 13 string-skip-right (was: fix for string-trim-right)
Date: Thu, 23 Jan 2014 21:54:01 +0900

On Thu, Jan 23, 2014 at 1:57 PM, John Cowan <address@hidden> wrote:
Alex Shinn scripsit:

> > (string-skip-right "abc   " char-whitespace? 4 4) => 2
> >
> > The correct result is #f; Riastradh confirmed that the correct semantics
> > throughout SRFI 13 for start-end is that they are conceptually applied
> > using substring/shared before anything else is done.
> >
> > A quick look at the reference implementation suggests that it needs
> > to trap the case where start = end, and always return #f then.
>
> Shouldn't it return ""?

No, you're confusing string-skip-right (the subject of this bug) with
string-trim-right (the subject of the previous bug).

Ah, sorry.
 
The former returns an index or #f [...]

FWIW, it has been suggested to me, and I tend
to agree, that the better API is the type-consistent
approach to return an index just before and just
after the start/end of the string, i.e. -1 for failed
-right and string-length for failed -left.  This is
what (chibi string) does for string-find, string-find-right,
etc., with a convenience string-find? when you
don't need the position.

-- 
Alex


reply via email to

[Prev in Thread] Current Thread [Next in Thread]