This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug in shared substrings?



> > This bit of code seems to demonstrate a bug with shared substrings. Can
> > someone confirm this, or else point out my mistake?

Thanks for the bug report, and the patch.  I've simply changed
string-set! to signal an error if the string argument is not a
writeable string.  In other words, the function `bug' in John
Redford's example is not correct Guile code, because you cannot modify
shared substrings.

I think Guile shouldn't have a substring-set! function.  The original
reason for making substrings read-only was to allow code to use
make-shared-substring without fear that the consumer of the shared
substring would munge it and wipe out the original.  Code should not
use make-shared-substring unless it can show that the original string
will not be munged.

These rules are pretty complicated, which is why I would like, in the
future, to get rid of make-shared-substring, and make all substrings
shared, with copy-on-write handling to preserve the appearance of
separate objects.