guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: string-map arg order


From: Dirk Herrmann
Subject: Re: string-map arg order
Date: Thu, 6 Sep 2001 19:12:18 +0200 (MEST)

On 6 Sep 2001, Marius Vollmer wrote:

> I wouldn't mind if string-ref and string-set! would take large
> performance hits but we would have an alterntive, more functional and
> list-like interface to strings as a replacement.  I'd say that
> scanning (with substrings as a result) and concatenation are useful
> operations that can be fast for variable-width encodings and can
> probably substitute for string-ref and string-set.

Not if you still allow for calls to string-set!.  Look at the example
below, which I copied from my latest mail to Alex:

  (define s <some string>)
  (define (foo c)
    (string-set! s (random-index (length s)) (random-character)))
  (string-for-each foo s)

During the iteration through string-for-each, the characters of `s´ can
change, which means that the relative byte positions of every character 
(except the first one) can change in every iteration of the loop.  Note
that this is completely independent of whether threading is used or not!

In other words, not even string-for-each and friends save you from
re-calculating the character index at every iteration.

Best regards
Dirk Herrmann






reply via email to

[Prev in Thread] Current Thread [Next in Thread]