[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] procedure identity
- To: Noah Lavine <noah.b.lavine@x>
- Subject: Re: [Scheme-reports] procedure identity
- From: Per Bothner <per@x>
- Date: Tue, 04 Jun 2013 23:54:24 -0700
- Cc: scheme-reports <scheme-reports@x>
- In-reply-to: <CA+U71=MhEuLbF+1X804H701t67wj10TgN4MkW_MFyndb4gf3ig@mail.gmail.com>
- References: <E1Uk03T-0000kt-7a@gjs-x1> <51AE7631.4050903@bothner.com> <CA+U71=MhEuLbF+1X804H701t67wj10TgN4MkW_MFyndb4gf3ig@mail.gmail.com>
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