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

Re: [Scheme-reports] procedure identity



On 06/04/2013 09:23 PM, Noah Lavine wrote:
> As I'm sure you're aware, there is a strong correspondence between
> procedures and records. Closures can be implemented as records holding
> state variables and code, and records can be implemented as special
> procedures. It would make sense to me that the rules for procedures and
> records would be the same. So it would be convenient if the result of
>
> (eq? (lambda (x) x) (lambda (x) x))

Note my example is different: It was the *same* identical
lambda expression being evaluated multiple times:

(define (maybe-negate negp)
    (if negp (lambda (x) (- x))
        (lambda (x) x)))

In that case a very natural (and desirable) optimization
is to re-write this to:

(define $lambda1$ (lambda (x) (- x)))
(define $lambda2$ (lambda (x) x))
(define (maybe-negate negp)
    (if negp $lambda1$
        $lambda2$))

> were the same as
>
> (define-record-type my-record make-my-record my-record?)
>
> (eq? (make-my-record) (make-my-record))
>
> It makes the most sense to me if both of these expressions return #f.

It may make sense, but if the specification prohibits the optimization
above then IMO it's wrong.

The problem is if you allow the optimization, then it becomes
difficult to specify when a "location tag" is created.
-- 
	--Per Bothner
per@x   http://per.bothner.com/

_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports