srfi-118- Simple adjustable-size strings
This SRFI defines two string mutating operations that can change
the length of the string:
Note that, in Gauche, the body of strings is immutable; when you mutate
a string, Gauche creates a fresh new string body and just switch a pointer
in the original string to point the new string body. So it is not a
problem to implement this SRFI in Gauche, but it also means you won’t
get any performance benefit by using these operations. Using immutable
you the same performance. (Be aware that the interface is slightly
different from the immutable versions.)
We provide this module only for the compatibility. Gauche-specific
programs should stay away from this module. Particulary, avoid
code like the example in SRFI-118 document (build a string by
append!-ing small chunks at a time)—they’re quadratic on Gauche.
The string argument must be a mutable string. Modify string by appending values, each of which is either a character or a string.
(rlet1 a (string-copy "abc") (string-append! a #\X "YZ")) ⇒ "abcXYZ"
The dst argument must be a mutable string. Replace dst between dst-start (inclusive) and dst-end (exclusive) with a string src. The optional arguments src-start and src-end limits the region of src to be used.
Be aware that the order of arguments differ from
string-replace (see SRFI-13 other string operations);
string-replace! resembles to
string-copy! (also in SRFI-13),
(rlet1 a (string-copy "abc") (string-replace! a 1 2 "XYZ")) ⇒ "aXYZc"