guile-devel
[Top][All Lists]
Advanced

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

Re: strings rationale


From: Marius Vollmer
Subject: Re: strings rationale
Date: 06 Aug 2001 23:54:30 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.102

Eric E Moore <address@hidden> writes:

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

But note that you can't just villy-nilly substitute modifying a string
with modifying a copy of that string.  These are two very different
things.  Mostly your function is either supposed to modify the string
it is handed from the outside, or it is supposed not to modify it. In
the first case it would be a violation of the specified behavior of
your function to modify a copy of the passed string, in the latter
case, it would be a violation to modify the passed string.  The
situation where a function is allowed to change a string when it finds
this convenient should be very rare.

(With copy-on-write, all strings would be mutable, but could secretly
share storage behind the scenes.)



reply via email to

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