mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
better fix for #618
This commit is contained in:
parent
d511b8e31d
commit
23f93cceb4
2 changed files with 62 additions and 57 deletions
|
@ -66,10 +66,7 @@
|
|||
(set! count (+ count 1))))
|
||||
(cont x index)))))
|
||||
(let wr ((x x))
|
||||
(check-shared
|
||||
x
|
||||
""
|
||||
(lambda (x shared?)
|
||||
(define (wr-one x shared?)
|
||||
(cond
|
||||
((pair? x)
|
||||
(display "(" out)
|
||||
|
@ -95,7 +92,7 @@
|
|||
(wr (car ls))
|
||||
(lp (cdr ls)))))
|
||||
(shared? ;; shared dotted tail
|
||||
(write ls out))
|
||||
(wr-one ls #f))
|
||||
(else
|
||||
(display " . " out)
|
||||
(wr ls))))))
|
||||
|
@ -121,7 +118,8 @@
|
|||
((eq? x #f) (display "#f" out))
|
||||
(else
|
||||
;; (display "#<unknown>" out)
|
||||
(write x out))))))))
|
||||
(write x out))))
|
||||
(check-shared x "" wr-one))))
|
||||
|
||||
(define write/ss write-with-shared-structure)
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
(define-syntax test-cyclic-io
|
||||
(syntax-rules ()
|
||||
((test-io str-expr expr)
|
||||
((test-cyclic-io str-expr expr)
|
||||
(let ((str str-expr)
|
||||
(value expr))
|
||||
(test str (write-to-string value #t))
|
||||
|
@ -48,6 +48,13 @@
|
|||
(test-io "(#0=(1 . 2) #1=(1 . 2) #2=(3 . 4) #0# #1# #2#)"
|
||||
(let ((a (cons 1 2)) (b (cons 1 2)) (c (cons 3 4)))
|
||||
(list a b c a b c)))
|
||||
(test-io "((1 . #0=#(2)) #0#)"
|
||||
(let ((vec (vector 2)))
|
||||
(list (cons 1 vec) vec)))
|
||||
(test-io "((1 . #0=#(2 #0#)) #0#)"
|
||||
(let ((vec (vector 2 #f)))
|
||||
(vector-set! vec 1 vec)
|
||||
(list (cons 1 vec) vec)))
|
||||
(test-cyclic-io "((1 . 2) (1 . 2) (3 . 4) (1 . 2) (1 . 2) (3 . 4))"
|
||||
(let ((a (cons 1 2)) (b (cons 1 2)) (c (cons 3 4)))
|
||||
(list a b c a b c)))
|
||||
|
|
Loading…
Add table
Reference in a new issue