[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Guile BUG: What's wrong with this?
From: |
David Kastrup |
Subject: |
Re: Guile BUG: What's wrong with this? |
Date: |
Sat, 07 Jan 2012 16:47:37 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) |
Mark H Weaver <address@hidden> writes:
> 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?
Mutating list operations are allowed on '() (and do not change it).
'(), the empty list structure, is eq? to itself regardless how you
arrived at it. I think it would give some logical symmetry if the same
held for "" and #(). "" is obviously a valid substring of either
mutable or immutable strings. The result of (string-append! x "")
should leave the immutability state of x alone. One rationale behind
that is more or less that the immutability is a property of the
characters of the string, and "" has no characters of its own and does
not contribute to the characters.
If there are predicates "immutable-string?" and "mutable-string?" (I
don't have Guilev2 installed), then "" would be the only string
satisfying both predicates.
Efficiency of implementation might make other choices preferable, but
that's what I would consider logically satisfying.
--
David Kastrup
- Re: Guile BUG: What's wrong with this?, (continued)
- Re: Guile BUG: What's wrong with this?, Andy Wingo, 2012/01/06
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/06
- Re: Guile BUG: What's wrong with this?, Mark H Weaver, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Mark H Weaver, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Mark H Weaver, 2012/01/09
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/09
- Re: Guile BUG: What's wrong with this?, Andy Wingo, 2012/01/09
- Re: Guile BUG: What's wrong with this?, Bruce Korb, 2012/01/09
- Re: Guile BUG: What's wrong with this?,
David Kastrup <=
- Re: Guile BUG: What's wrong with this?, Mark H Weaver, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Mark H Weaver, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Mike Gran, 2012/01/07
- Re: Guile BUG: What's wrong with this?, Ludovic Courtès, 2012/01/07
- The empty string and other empty strings, Ludovic Courtès, 2012/01/10
- Re: The empty string and other empty strings, Mike Gran, 2012/01/10
- Re: The empty string and other empty strings, Mark H Weaver, 2012/01/10
- Re: The empty string and other empty strings, Mike Gran, 2012/01/10
- Re: The empty string and other empty strings, Mark H Weaver, 2012/01/10
- Re: The empty string and other empty strings, David Kastrup, 2012/01/10