[plt-scheme] Re: When does eqv? differ from eq? , from equal?
----- Original Message -----
From: "Felix S Klock II" <pnkfelix at ccs.neu.edu>
To: "Jos Koot" <jos.koot at telefonica.net>
Sent: Tuesday, October 07, 2008 3:17 PM
Subject: Re: [plt-scheme] Re: When does eqv? differ from eq? , from equal?
> Jos-
>
> On Oct 7, 2008, at 8:44 AM, Jos Koot wrote:
>
>> You're right:
>> 1: I did not check the syntax. (I have now)
>> 2: After correction of the syntax I find #t for both eq? and equal?
>> (#lang scheme of PLT)
>> Thanks.
>
>
>> Yet a content oriented implementation of equal? could produce #f, or is
>> it prohibited to produce #f when eq? returns #t? To me this is not
>> immediately clear when looking into R6RS. But then, R6RS does say
>> nothing about equality of structures (or records, or does it?)
>
Felix:
> No, equal? can not produce #f for your second example.
>
> ----
>
> I think you are misunderstanding either the evaluation model or the
> value/object model of Scheme, or both. I cannot tell which is the case,
> so I will summarize answers for each potential misunderstanding below.
>
> 1.) Scheme's evaluation model for invocations is Call-By-Value (CBV), as
> opposed to Call-By-Name or Lazy. Therefore all of the expressions given
> as operands to an invocation of the equal? procedure must be evaluated
> down to values before equal? is itself invoked. Therefore the invocation
> of set-x-y! is going to take place before equal? is invoked.
Me:
Correct. I mean, I was mistaken in this respect. After both actual arguments
have been evaluated, they have the same content. I feel silly :(.
Thanks again :)
Felix:
>
> 2.) Scheme's value/object model says identifiers denote locations on the
> heap. Thus when you evaluate the identifier sxa or sxb, it evaluates to
> a reference to a heap-allocated structure; it does *not* make a new copy
> of the structure.
>
> Therefore the expressions <<sxb>> and <<(begin (set-x-y! sxb 2) sxb)>>
> both actually evaluate to the *same* value: the location on the heap
> denoted by the identifier sxb.
>
> ----
>
> If Scheme's evaluation model were Call-By-Name, then the internal
> operation of equal? might inspect the structure of sxb both before and
> after it is mutated, and thus observe a difference in the internal
> structure. (Though the implementations of equal? that are most obvious
> to me would traverse the structure of the first and second operands in
> parallel, and thus even in a Call-By-Name variant of Scheme, equal? could
> still return #t; but the point is that it might not.)
>
> If Scheme's value/object model were such that identifiers denoted complex
> structures directly, rather than locations on the heap, then the
> evaluation of sxb could very well create a copy of the structure that was
> distinct from the one yielded by the expression
> (begin (set-x-y! sxb 2) sxb)
> In this case, the left and right actual arguments in the invocation of
> equal? might be distinct structures. Or they might be the same,
> depending on what order the two expressions were evaluated in. (For
> example, if the operand expressions were evaluated right-to-left, then
> equal? would still return #t for this particular example.)
>
Me:
>> PS, You are free to expose my mistakes/errors to the PLT list :)
>
Felix:
> I wanted to give you the opportunity to correct the error on your own.
Me:
Hence now I do expose myself to the list by cc-ing this message, your
exposure of my mistake included. Thanks for your kind gesture in your
previous mail and the hint in the latest one
Jos
>
> -Felix
>
>
>