guile-devel
[Top][All Lists]
Advanced

[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 12:07:41 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

David Kastrup <address@hidden> 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



reply via email to

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