Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!mintaka!ai-lab!zurich.ai.mit.edu!jinx From: jinx@zurich.ai.mit.edu (Guillermo J. Rozas) Newsgroups: comp.lang.scheme Subject: Re: eqness of procedures Message-ID: Date: 11 May 91 22:10:04 GMT References: <9105080039.aa09228@mc.lcs.mit.edu> <1991May8.063427.25012@Think.COM> Sender: news@ai.mit.edu Reply-To: jinx@zurich.ai.mit.edu Organization: M.I.T. Artificial Intelligence Lab. Lines: 78 In-reply-to: hanche@imf.unit.no's message of 11 May 91 14:40:38 GMT In article hanche@imf.unit.no (Harald Hanche-Olsen) writes: Path: ai-lab!mintaka!think.com!sdd.hp.com!wuarchive!udel!rochester!kodak!uupsi!sunic!ugle.unit.no!hanche From: hanche@imf.unit.no (Harald Hanche-Olsen) Newsgroups: comp.lang.scheme Date: 11 May 91 14:40:38 GMT References: <9105080039.aa09228@mc.lcs.mit.edu> <1991May8.063427.25012@Think.COM> Sender: news@ugle.unit.no Organization: The Norwegian Institute of Technology, Trondheim, Norway. Lines: 20 In article alan@lcs.mit.edu (Alan Bawden) writes: Well, but certainly (eq? (cons 1 2) (cons 1 2)) is required to be false. I can imagine a programmer thinking it would be convenient if every evaluation of a LAMBDA-expression resulted in a unique (in the sense of EQ?) closure. If I have understood it right, that form is required to be false because of the existence of procedures like set-car! and set-cdr! which could change equal-looking objects to look different. You cannot change a closure in an analogous way. So what is so convenient about (lambda (x) x) not being eq? to (lambda (x) x) ? - Harald Hanche-Olsen Division of Mathematical Sciences The Norwegian Institute of Technology N-7034 Trondheim, NORWAY You cannot? What about things like (let ((loc 'unknown)) (lambda (new) (let ((old loc)) (set! loc new) old))) Should two such closures be EQ?/EQV? when they have different environments? Should such a closure not be EQ?/EQV? to itself? Such closures behave very much like structures built out of mutable pairs, and should behave very much like them as far as EQ?/EQV? are concerned. In general, the intent was that LAMBDA is very much like CONS, and every time a LAMBDA expression is evaluated, you get a different object (in the sense of EQ?/EQV?). Note that the formal semantics represents procedure objects as pairs of locations and functions, and models this behavior exactly. This restriction was relaxed somewhat in order to allow compilers to merge procedure objects that it can prove will always operate indistinguishably. In other words, it is spurious to make procedures distinct when only EQ?/EQV? would be able to tell them apart. Since determining function equivalence is an undecidable problem, you cannot expect implementations to do it perfectly, and rather than imposing precise rules that might be improved later, we left the decision to the implementors. Thus (eqv? (lambda (x) x) (lambda (y) y)) may be either true or false. Similarly for (define (make-new-procedure) (lambda (y) y)) (eqv? (make-new-procedure) (make-new-procedure))