guile-devel
[Top][All Lists]
Advanced

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

Re: strings rationale


From: Eric E Moore
Subject: Re: strings rationale
Date: 06 Aug 2001 20:43:20 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

>>>>> "Tom" == Tom Lord <address@hidden> writes:

Tom> No, you don't have to check for read-onliness before using
Tom> `string-set!'.  `string-set!'  checks internally, and signals an
Tom> error if passed an immutable string.

If you want your code to not throw errors, you have to check for
read-onliness.   I thought we all assumed string-set! would throw an
error if passed a read-only string...  Sure, you could do:

(if (not (false-if-exception (string-set! str n #\q)))
    (begin 
      (set! str (copy-string str))
      (string-set! str n q\q)))

or whatever, but you still need logic to check that the string
someone passed you is read-only or not...   IMO, copy-on-write is
acceptable, but error throwing is a little messy.  You could just
accept your code will fail on read-only strings, but that's not always
the friendliest thing to do.

  -Eric




reply via email to

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