[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

reply via email to

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