Re: New draft of SRFI 130: Cursor-based string library William D Clinger 21 May 2016 17:23 UTC
Alex Shinn wrote: > I totally missed that - the chibi versions have never taken > an initial string argument to string-cursor</>[=]?. Do we > really need it? SRFI 130, as it exists today (on what I believe to be the last day before it enters final status), says those cursor comparison procedures take three arguments, the first being a string. So long as SRFI 130 says that, the sample implementations need to take that number of arguments. As for whether we really need SRFI 130, that's a different question. I think the better approach is to define a new data type of immutable texts, using strings only for those few use cases that really need mutation. Immutable texts can combine O(1)-time random access with the spatial efficiency associated with UTF-8. John Cowan had written a proposal along these lines, but he called them spans instead of texts and made the proposed specification more complicated than necessary. I suspect that is why SRFI 130 was written. In my opinion, however, SRFI 130 doesn't do the job that needs doing. I spent this morning writing a test program for Larceny's implementation of SRFI 130, which is a fairly simple wrapper around Olin's reference implementation for SRFI 13. The test program assumes cursors are the same as indexes, but it may be of some interest regardless. The test program is in lib/SRFI/test/srfi-130-test.sps7 at Larceny's development site, https://github.com/larcenists/larceny That test program uncovered two very old bugs in Olin's implementation of SRFI 13, and it might be a good idea for people who are using that old implementation as a starting point for SRFI 130 to be aware of those bugs. Basically, Olin's definitions of string-filter and string-delete swapped the order of the first two arguments, and his definition of string-trim-right ignored the optional start argument. For details, see the history of Larceny's lib/SRFI/srfi/%3a13.sls file. Note also that the test program many of us have been using for SRFI 13 contains incorrect tests that sanctioned those bugs. Will