| 1 |
;;; Copyright (c) 2012 Aaron W. Hsu <[email protected]> |
| 2 |
;;; |
| 3 |
;;; Permission to use, copy, modify, and distribute this software for |
| 4 |
;;; any purpose with or without fee is hereby granted, provided that the |
| 5 |
;;; above copyright notice and this permission notice appear in all |
| 6 |
;;; copies. |
| 7 |
;;; |
| 8 |
;;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL |
| 9 |
;;; WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED |
| 10 |
;;; WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE |
| 11 |
;;; AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL |
| 12 |
;;; DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA |
| 13 |
;;; OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 14 |
;;; TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 15 |
;;; PERFORMANCE OF THIS SOFTWARE. |
| 16 |
|
| 17 |
(library (srfi :38 with-shared-structure) |
| 18 |
(export write-with-shared-structure |
| 19 |
(rename (write-with-shared-structure write/ss)) |
| 20 |
read-with-shared-structure |
| 21 |
(rename (read-with-shared-structure read/ss))) |
| 22 |
(import (chezscheme)) |
| 23 |
|
| 24 |
(define write-with-shared-structure |
| 25 |
(case-lambda |
| 26 |
[(obj) |
| 27 |
(write-with-shared-structure obj (current-output-port))] |
| 28 |
[(obj port) |
| 29 |
(parameterize ((print-graph #T)) |
| 30 |
(write obj port))] |
| 31 |
[(obj port optarg) |
| 32 |
(assertion-violation 'write-with-shared-structure |
| 33 |
"this implementation does not support optarg")])) |
| 34 |
|
| 35 |
(define read-with-shared-structure read) |
| 36 |
|
| 37 |
) |