On 09/19/2009 06:46 PM, Aubrey Jaffer wrote:
> Below are the occurences of string-set! in SLIB. One frequent pattern
> of use is to make a string using MAKE-STRING; then fill it with
> STRING-SET!. Accumulating characters with STRING-APPEND is a bad
> idea; it turns a O(N) process into O(N^2). So I guess lists-of-chars
> and LIST->STRING would be the alternative to MAKE-STRING with
> STRING-SET!.
The solution is a (mutable) text or string-buffer type,
with a text-append! operation.
"Small Scheme" probably only needs:
(make-text)
(text-append! TEXT CHARACTER)
(text-append! TEXT STRING)
(text->string TEXT)
It is easy to emulate these in "legacy Scheme", so
they shouldn't cause any problems for SLIB. (A TEXT
could be represented as a pair containing a mutable string
plus an integer length. Or if you don't have mutable
strings: a pair of a vector of characters plus an integer.)
"Big Scheme" might add insertion, deletion, slices, Unicode
normalization, and whatever.
--
--Per Bothner
[email protected] http://per.bothner.com/
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss