shhyou / ypsilon-fork

Automatically exported from code.google.com/p/ypsilon
Other
0 stars 0 forks source link

missing support for graph structures in the reader (Ikarus compatibility, non-R6RS) #58

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This is NOT for R6RS compatibility, just for Ikarus compatibility.

The following works under Ikarus:

;;; proof.sls --
(import (rnrs)
  (rnrs mutable-pairs (6)))
(define a '#0=((:class . #0#)
           (:name . ciao)))
(define b (let ((c '((:class . #f)
             (:name . ciao))))
        (set-cdr! (car c) c)
        c))
(write a)(newline)
(write b)(newline)
(write (equal? a b))(newline)
;;; end of file

and outputs:

#0=((:class . #0#) (:name . ciao))
#0=((:class . #0#) (:name . ciao))
#t

it is rarely useful, but in those rare cases: useful.

The graph notation is described, at present only informally, in the
Ikarus guide section 3.5 "Printing" (documentation of the PRINT-GRAPH
parameter).

PLT Scheme also supports some form of it in non-R6RS mode (cannot post
a working example due to the plethora of languages and the misterious
ways to activate a reader) described in the guide section 12.6.16
"Reading Graph Structure".

http://docs.plt-scheme.org/reference/reader.html#(part._parse-graph)

Original issue reported on code.google.com by mrc....@gmail.com on 23 Nov 2008 at 9:07

GoogleCodeExporter commented 9 years ago
Thank you for your message.
I have updated svn trunk and revision 285 support shared structures. Please try!
Note: You need --compatible option or #!compatible comment to enable shared
structures notation.

$ ypsilon
Ypsilon 0.9.6-trunk/r285 Copyright (c) 2008 Y.Fujita, LittleWing Company 
Limited.
> (define lst (cons '#3=(p q r) '(x y . #3#)))
error in read: invalid lexical syntax #3
  ..."/dev/stdin" line 1

$ ypsilon --compatible
Ypsilon 0.9.6-trunk/r285 Copyright (c) 2008 Y.Fujita, LittleWing Company 
Limited.
> (define lst (cons '#3=(p q r) '(x y . #3#)))
> lst
((p q r) x y p q r)
> (car lst)
(p q r)
> (cdddr lst)
(p q r)
> (eq? (car lst) (cdddr lst))
#t
> (cons '#2=#3=(p q r . #2# ) '(x y . #3#))
(#1=(p q r . #1#) x y . #1#)

$ cat proof2.sls
#!compatible
(import (rnrs) (rnrs mutable-pairs (6)))
(define a '#0=((:class . #0#)
           (:name . ciao)))
(define b (let ((c '((:class . #f)
             (:name . ciao))))
        (set-cdr! (car c) c)
        c))
(write a)(newline)
(write b)(newline)
(write (equal? a b))
(newline)

$ ypsilon proof2.sls
#1=((:class . #1#) (:name . ciao))
#1=((:class . #1#) (:name . ciao))
#t

Original comment by y.fujita...@gmail.com on 25 Nov 2008 at 3:19

GoogleCodeExporter commented 9 years ago
From what I have tested so far, this workds. Thanks.

Original comment by mrc....@gmail.com on 1 Dec 2008 at 6:47

GoogleCodeExporter commented 9 years ago
Thank you for your reply. I close this issue :)
-- fujita

Original comment by y.fujita...@gmail.com on 3 Dec 2008 at 4:44