David Kastrup <[email protected]> writes:
> 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.
Excellent point. The R5RS says that `list' returns "a newly allocated
list", but that's obviously not true for (list). So I guess we can take
this as a precedent that the "newly allocated" language does not
necessarily apply in the 0-element case.
I wonder if the R7RS should make this point explicit. It's obvious for
lists, but not for vectors or strings.
> The result of (string-append! x "") should leave the immutability
> state of x alone.
There's no `string-append!' nor anything like it, because in Scheme the
length of strings is fixed. Only the characters themselves can be
changed, not the length.
> If there are predicates "immutable-string?" and "mutable-string?" (I
> don't have Guilev2 installed), then "" would be the only string
> satisfying both predicates.
There are no such predicates, and I don't see any good use for them. If
you need to check whether a string is mutable, then you shouldn't be
mutating it anyway.
Anyway, mutability is not a property of strings in particular, but of
all objects. Or at least it should be. Right now, we don't enforce
immutability of literal lists or vectors, but we should.
Mark