Re: New draft (#2) of SRFI 140: Immutable Strings
Per Bothner 01 Aug 2016 01:35 UTC
On 07/31/2016 06:00 PM, Arthur A. Gleckler wrote:
> I've just published draft #2 of SRFI 140. It was submitted
> by Per Bothner, the author. Among other things, Per has
> renamed the SRFI, originally called Strings for WG2, to
> Immutable Strings.
>
> <http://srfi.schemers.org/srfi-140/>
Thank you again!
> Here's the diff:
>
> <https://github.com/scheme-requests-for-implementation/srfi-140>
Well, actually here:
https://github.com/scheme-requests-for-implementation/srfi-140/commit/3d522631c5866cde327f8374736e14bead2ccafd
In addition to renaming the SRFI (since I think this proposal makes sense whether or not
it makes it into WG2), there are other major changes:
* Added prototypes for many procedures, following (and copying from) SRFI-135.
This isn't complete, but should make things much clearer. I didn't add actual
specification of functions that are the same (except for renaming to string-)
in R7RS and/or SRFI-135. I figure less work for people comparing them ...
* I decided make-string should always return a mutable string.
The count argument can be left out, defaulting to zero, following a suggestion from Jim Rees.
That's the most sensible starting value, working well with SRFI-118 string-append!.
* Added string-repeat, generalized to take either a string or a character.
The latter case handles the use-case of make-string but returning an immutable result.
* Removed string->istring - it is subsumed by substring.
I changed substring to make the [start end] arguments optional.
* Generalized string-replicate to leave out the first two arguments.
That makes it easy to use as a variant of string-copy that returns an
immutable result.
* SRFI-135 has a confusing and redundant number of procedures for converting textual to textual,
making a copy, or creating a substring. I came up with a more minimal set:
- string-copy - make a mutable copy
- substring - creates an immutable copy with optional structure sharing. Specifically,
result may be the same as the argument string if [start end] are defaulted.
- string-replicate - creates a fresh immutable copy (with no sharing)
All of the take optional [start end] in the same way.
--
--Per Bothner
xxxxxx@bothner.com http://per.bothner.com/