[racket] how does equal? determine with syntax objects?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Thu Aug 7 21:49:10 EDT 2014

As a partial answer to your question, syntax objects internally have
lots of caches that are most definitely mutable, but I don't think
that there is any way you can observe the mutation without getting out
a stopwatch.

Robby

On Thu, Aug 7, 2014 at 8:44 PM, Alexander D. Knauth
<alexander at knauth.org> wrote:
>
> On Aug 7, 2014, at 8:53 PM, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>
>
> Here are some examples:
>
> (equal? #'(lambda (x) x) #'(lambda (x) x))
>
> #f
>
>
> For these the source locations would still be different.
>
> (define so #'(lambda (x) x))
> (equal? so so)
>
> #t
>
>
> For these they are eq?.
>
>
>
> Does equal? simply use eq? for syntax objects?
> This example says probably, or am I still missing something?
> (define stx #'(lambda (x) x))
> (equal? stx (datum->syntax stx (syntax-e stx) stx stx stx))
>
> Are syntax objects mutable? If so, how would you define a function like eq?
> say syntax-eq? without using the built-in equality?
>
> Are syntax objects immutable? Why should they be immutable? How does equal?
> work on such structures normally?
>
>
> I was under the impression that syntax objects were immutable, but I don’t
> really know.
> And anyway, for mutable vectors, strings, byte-strings, and structs, equal?
> still checks each element.
>
> See HtDP on extensional and intensional equality. — Matthias
>
>
> Where?  I have read a lot of HtDP, and looked at it again just now, but I
> don’t remember anything about this, and couldn’t find anything either.
> In the BSL docs for eq? and eqv? it mentions extensional and intensional,
> but doesn’t explain anything.
> In Realm of Racket there was a bit about that, but that doesn’t really tell
> me anything about syntax objects.
>
>
> On Aug 7, 2014, at 5:58 PM, Alexander D. Knauth wrote:
>
> How does equal? determine whether two syntax objects are equal?
>
> Does it simply use eq?, or does it check the syntax-e, lexical context,
> srcloc and properties?
>
>
>
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users
>
>
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>


Posted on the users mailing list.