# [plt-scheme] printing shared structures

On Jan 29, 2008 11:25 AM, Prabhakar Ragde <plragde at uwaterloo.ca> wrote:
>* Robby Findler wrote:
*>* >> While we are on the subject, if I have two structures, each of which
*>* >> involves sharing but no cycles, and I evaluate (print-graph #t) and then
*>* >> print them, will they print identically iff they are equal? in the R6RS
*>* >> sense? --PR
*>*
*>* > I think so, and I think that should also be true if there are cycles.
*>* >
*>* > In the case that there are no cycles, then you don't even need to turn
*>* > on print-graph for that to be true, iiuc.
*>*
*>* It's not iff, unless I misunderstand equal?.
*>*
*>* (define a (cons 1 empty))
*>* (define b (cons a a))
*>*
*>* (define c (cons 1 empty))
*>* (define d (cons 1 empty))
*>* (define e (cons c d))
*>*
*>* (display b)
*>* (newline)
*>* (display e)
*>* (newline)
*>*
*>* The two lines printed are identical in Pretty Big, but if I add
*>* (print-graph #t), they're not. --PR
*
Oh, right you are. If they have no cycles and print-graph is _false_,
then the printed representations should be equal when r6rs wants them
to be equal. That is, r6rs says (and I'm paraphrasing) "if the
(potentially infinite) tree unrolling of the two structures are the
same, then equal? should return #t, and #f otherwise".
Now I don't think that there is a similar claim to be made for cyclic
structures.
Robby