[plt-scheme] Procedure equality

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Apr 30 08:07:51 EDT 2009

On Thu, Apr 30, 2009 at 7:01 AM, Abdulaziz Ghuloum <aghuloum at gmail.com> wrote:
>
> On Apr 30, 2009, at 2:52 PM, Robby Findler wrote:
>
>> I think that, in principle, compiler optimizations can get in the way
>> of that working properly, but as far as I know, it will only make more
>> things eq? not fewer (as compared to what you might think).
>
> It can go both ways.
>
> For example, the expression
>
>  (let ([foo (lambda () 42)])
>    (eq? foo foo))
>
> might be transformed after copy propagation to
>
>  (eq? (lambda () 42) (lambda () 42))
>
> and this expression may evaluate to #f.
>
> The same nonguarantee applies to numbers (afaik).  For example
>
>  (let ([x 1.0]) (eq? x x))
>
> may return #f.

Right, thanks Aziz. I should have clarified that I don't believe
mzscheme does that (but mzscheme's compiler has gotten fancier since I
last asked Matthew about this point).

MzScheme does do this:

  > (define (f x) (lambda (y) 1))
  > (eq? (f 1) (f 2))
  #t

because the lambda expressions have no free variables, so there is no closure.

Robby


Posted on the users mailing list.