Am Mo., 24. Feb. 2020 um 19:53 Uhr schrieb Per Bothner <xxxxxx@bothner.com>:
Am I missing something in the translate-space-to-newline example?
There seems to be a missing
     (set! result ....)
wrapping each call to string-linear-append!.

FWIW: I've expressed before my skepticism of linear-update procedures.
I think it's an inherently hard-to-use error-prone way of working.
Changing string-replace! and string-append! to macros would have
the same portability and performance benefits.

You want to be able to apply the linear-update procedures on temporary values. In a call to `string-linear-append!' the `string' argument does not have to be a variable reference.

From a theoretical point of view, I like the idea of linear update procedures alot; what is missing is a way to communicate warnings if certain results are not used (like in gcc's unused-result warning.

We should think how such a thing can be made to work in the Scheme language.

Marc
 

My suggestion: Define a new SRFI that is the same as SRFI-118, except
that string-replace! and string-append! are syntax.
On a Kawa-like-system:

(define-syntax string-append!
   (syntax-rules ()
     ((_ r s ...)
      (begin
        (srfi-118-string-append! r s...)
        (set! r r) ;; to catch misuse
        ))))

Portable implementation:

(define-syntax string-append!
   (syntax-rules ()
     ((_ r s ...)
      (set! r (internal-string-linear-append! r s...)))))

If you're going to put my name on this, you should note my
lack of endorsement.
--
        --Per Bothner
xxxxxx@bothner.com   http://per.bothner.com/


--
Prof. Dr. Marc Nieper-Wißkirchen
 
Universität Augsburg
Institut für Mathematik
Universitätsstraße 14
86159 Augsburg
 
Tel: 0821/598-2146
Fax: 0821/598-2090
 
E-Mail: xxxxxx@math.uni-augsburg.de
Web: www.math.uni-augsburg.de/alg/mitarbeiter/mnieper/