guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guile: What's wrong with this?


From: David Kastrup
Subject: Re: Guile: What's wrong with this?
Date: Wed, 04 Jan 2012 18:49:13 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux)

Andy Wingo <address@hidden> writes:

> On Wed 04 Jan 2012 12:14, David Kastrup <address@hidden> writes:
>
>> Andy Wingo <address@hidden> 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




reply via email to

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