[Top][All Lists]

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

Re: Guile BUG: What's wrong with this?

From: Mark H Weaver
Subject: Re: Guile BUG: What's wrong with this?
Date: Sat, 07 Jan 2012 10:00:23 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Bruce Korb <address@hidden> writes:

> On 01/06/12 15:11, Mark H Weaver wrote:
>> Bruce Korb<address@hidden>  writes:
>>> scm_from_locale_stringn() makes an optimization when the length is zero.
>>> It returns an immutable string of length zero.
>> Good catch!
>>> Two possible fixes:
>>> 1. remove the "optimization"
>>> 2. check the length in scm_string_upcase_x before choking.
>> I see a third possible fix, which I think I like best:
>> 3. Make scm_nullstr into a mutable string.  After all, it can't be
>>     changed anyway, and the _only_ reference to it is from
>>     scm_from_stringn, so the result should always be mutable.
>> What do other people think?
>>      Mark
> I think you are presuming that that is the only source of zero length
> immutable strings.  Are you completely certain?

Empty string literals ("") in the program text are still immutable, so
(string-upcase! "") still throws an error.

I admit that this is an arguable point.  Section 3.4 (Storage model) of
the R5RS (and the R7RS draft) says "It is an error to attempt to store a
new value into a location that is denoted by an immutable object."  An
empty string denotes no locations, so perhaps this should not be an
error after all.

The right place to fix this would probably be in
`scm_i_string_start_writing' (strings.c).

What do other people think?


reply via email to

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