Question #11 "What immutable text library should R7RS-large provide?" of the Red Edition Ballot
is missing the alternative I was arguing for last month on the srfi-135 list:
http://srfi-email.schemers.org/srfi-135/msg/3849905
http://srfi-email.schemers.org/srfi-135/msg/3850401
Basically, the idea is to unify the concepts of SRFI-135 "text"
and R7RS "immutable string". We would formalize the distinction between
immutable and immutable strings, including adding a procedure immutable-string?
(though preferably under some other name). The SRFI-135 type "textual" is renamed
to the R7RS type "string", and the SRFI-135 type "text" (preferably under some
other name) becomes a subtype of "string".
string
- immutable strings / texts (string-set! throws exception; guaranteed O(1) string-ref)
- mutable strings (string-set! allowed - need not be O(1), nor does string-ref))
We could use the name "text" for "immutable strings" but I would prefer a name
like "istring" or "fstring" that makes it clear it is a sub-type of "string".
The procedures of SRFI-135 would be classified into two categories:
(1) Ones that returns a text; or a list/vector of text (i.e. text-split); plus text? :
These should retain the text- prefix (or some alternative new prefix,
such as istring- or fstring-).
(2) All the other ones should be renamed string-xxx. This assumes no conflict
with existing (or proposed) string- procedures; if there are conflicts they
should be considered on a case-by-case basis.
We might consider changing these traditional string procedures to return
immutable strings: string, string-upcase, string-downcase, string-foldcase, substring,
string-append, list->string, and string-map. (Though of course there has to be a
library with backward-compatible versions that return mutable strings.)
I'd also include SRFI-118's string-append! and string-replace! for mutable strings.
Again, I dislike this balloting process throwing a huge kitchen sink of proposed
additions without chance for reflection or nuance or discussion. Note that SRFI-135
is not yet final - and my proposal was dismissed as not suitable for SRFI-135 as
a standalone portable library. However, in the context of an updated Scheme
standard it is *not* out of place.
I can try to throw together a more detailed "Strings for WG2" proposal in the form
of a SRFI if there is interest.
--
--Per Bothner
p...@bothner.com http://per.bothner.com/