Andy Wingo <wi...@pobox.com> writes: > On Wed 04 Jan 2012 12:14, David Kastrup <d...@gnu.org> writes: > >> Andy Wingo <wi...@pobox.com> writes: >> >>> We could add a compiler option to turn string literals into >>> (string-copy FOO). Perhaps that's the thing to do. >> >> What for? It would mean that a literal would not be eq? to itself, a >> nightmare for memoization purposes. > > (eq? "hello" "hello") > > This expression may be true or false. It will be true in some > circumstances and false in others, in all versions of Guile.
To itself. Not to a literal written in the same manner. (define (zap) "hello") (eq? (zap) (zap)) This expression may not choose to be true or false. >> And for what? For making code with explicitly undefined behavior >> exhibit a particular behavior that is undesirable in general. > > The Scheme reports and the Guile manual are both positive and negative > specification: they require the implementation to do certain things, > and they allow it to do certain others. Eq? on literals is one of the > liberties afforded to the implementation, and with good reason. > Correct programs don't assume anything about the identities (in the > sense of eq?) of literals. Of _different_ literals spelled in the same way. But one and the same literal has to be eq? to itself. It can't just replace itself with a non-eq? copy on a whim. -- David Kastrup