Java has StringBuffer, Python has StringIO, R7RS has open-output-string.
 Add seek support to ports in general and there you have it.    This gives
implementors more flexibility as to speed/space trade-offs rather than make
the string type all things to all people.   Just my thoughts...



On Tue, Jul 1, 2014 at 5:26 PM, Per Bothner <[email protected]> wrote:

> I'm working on improving Kawa's Unicode support to
> be spec-compliant:
>
> https://sourceware.org/ml/kawa/2014-q2/msg00077.html
>
> I have two related questions/issues:
>
> (1) The Chibi "cursor" API for fast O(1) string access seems
> reasonable:
>
> https://code.google.com/p/chibi-scheme/source/browse/doc/chibi.scrbl
>
> However, there are no functions for string mutation - i.e. the
> replacement for string-set!.  Anyone implemented or designed such?
>
> (2) Once we have variable-length characters (UTF-8 or UTF-16)
> stored in a buffer, then any string that you can mutate with
> string-set! inherently becomes a variable-length string.  So
> we might as well let the Scheme programmer make use of that.
> I'm thinking of adding a general function:
>
> (string-replace! to to-start to-end from [from-start [from-end]])
>
> I.e. this is a generalization of string-copy! but it replaces the
> substring of to from to-start to to-end by from (or a substring thereof).
>
> It would also be useful to have an append-at-end function, since that may
> be the most common use-case for mutable strings:
>
> (string-append! to val ...)
>
> where each val is a character or a string that is appended to to.
>
> I.e. (string-append! dst-str src-str ...)
> is equivalent to:
>    (string-replace! to (string-length to) (string-length to)
>      (string-append src-str ...))
> (Characters are expanded to strings as needed.)
>
> Does this seem reasonable?  Any prior art I should know about?
> --
>         --Per Bothner
> [email protected]   http://per.bothner.com/
>
> _______________________________________________
> Scheme-reports mailing list
> [email protected]
> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
>
_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

Reply via email to