| From: Thomas Lord <[email protected]>
 | Date: Sat, 19 Sep 2009 15:49:47 -0700
 | 
 | On Sat, 2009-09-19 at 01:24 -0400, John Cowan wrote:
 | [....]
 | > 2) Algorithms where you want to modify strings in the middle are rare,
 | 
 | Claims like this always make the hairs on the back of my 
 | neck stand up.  There are two problems with them.
 | First, there isn't a really good empirical way to establish
 | such claims.   Second, rarity per se, is not the most 
 | important consideration.
 | 
 | Surely if we scan the source for PLT or various Scheme
 | compilers, SLIB, and similar systems we'll find that 
 | string mutation is less common than immutable uses of
 | strings.   Well, I haven't actually *checked* but I wouldn't
 | be surprised.   Still, that tells us little about what
 | code there is that we can't see and won't here about and it
 | tells us even less about what kinds of code people will 
 | want to write in 3 years.

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!.

                              -=-=-=-=-

  array.scm:375:  ((if (string? store) string-set! vector-set!)

To implement uniform character arrays.

  byte.scm:89:      (string-set! new idx (integer->char (byte-ref bts idx))))))

Byte-vectors implemented from strings.

  chap.scm

CHAP:NEXT-STRING increments (in the lexicographic order) a copy of a
given string.

  format.scm:725:             (string-set! format:fn-str format:fn-len c)
  format.scm:728:             (string-set! format:en-str format:en-len c)
  format.scm:769:             (string-set! format:en-str format:en-len c)
  format.scm:779:         (string-set! format:fn-str i
  format.scm:785:         (string-set! format:fn-str i #\0))))
  format.scm:794:      (string-set! format:fn-str (- i n) (string-ref 
format:fn-str i))))
  format.scm:805:              (string-set! format:fn-str 0 #\1)
  format.scm:810:      (string-set! format:fn-str i (integer->char
  format.scm:837:    (string-set! format:fn-str format:fn-len #\0)
  format.scm:1631:              (string-set! cap-str i (char-downcase c))
  format.scm:1634:                (string-set! cap-str i (char-upcase c)))))))))

One use is capitalizing a copy of a string.  The other occurences are
harder to figure.

  genwrite.scm:261:              (string-set! result k (string-ref str j))

Fills in the result of a call to MAKE-STRING.

  getparam.scm:109:                                (string-set! str i #\-))))))

Converting space to "-" in copy of a string.

  http-cgi.scm:

HTTP:READ-QUERY-STRING and CGI:READ-QUERY-STRING fill strings returned
by MAKE-STRING.

  lineio.scm:60:          (string-set! str i char)))))

READ-LINE! fills an argument string with characters read from a port.

  matfile.scm:129:               (string-set! namstr idx (read-char port)))

MATFILE:READ-MATRIX reads characters into a string returned by MAKE-STRING.

  printf.scm:

SPRINTF stores output into string passed as argument.

  sc2.scm:

SUBSTRING-MOVE-LEFT!, SUBSTRING-MOVE-RIGHT!, and SUBSTRING-FILL!

  sc4opt.scm:35:      (string-set! s i obj)))

STRING-FILL!

  scanf.scm:105:                              (string-set! str i 
(read-input-char))))))))
  scanf.scm:225:                     (string-set! str i (read-input-char)))))

Filling string made by MAKE-STRING.

  strcase.scm:

STRING-UPCASE!, STRING-DOWNCASE!, and STRING-CAPITALIZE!

  strport.scm:39:                    (string-set! buf i c)

CALL-WITH-OUTPUT-STRING fills string created by MAKE-STRING or
extended with STRING-APPEND.

  transact.scm:116:                     (string-set! str idx (read-char iport))
  transact.scm:121:            (string-set! name idx (read-char iport))

WORD-LOCK:CERTIFICATE fills result of MAKE-STRING with characters read
from a port.

  xml-parse.scm:263:      (string-set! buffer i c)
  xml-parse.scm:313:                    (string-set! buffer i c)
  xml-parse.scm:331:                (string-set! buffer i c)
  xml-parse.scm:349:        (else (string-set! buffer idx chr))))))

Seems to be filling result of MAKE-STRING with read characters.

  yasyn.scm:27:                       (cons string-ref string-set!))

Not a clue.

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to