[gambit-list] Limiting object external representation
Marc Feeley
feeley at iro.umontreal.ca
Mon Aug 6 00:15:07 EDT 2007
Some users of Gambit have experienced problems using the REPL to
debug programs which create circular structures because the external
representation used by default by "write", "pretty-print", and "pp"
does not handle circular structures or deeply nested structures very
well (i.e. infinite loop).
This issue can be addressed by changing the readtable associated with
the REPL's output port. This can be done with code such as:
(define (repl-ctrl sharing-allowed? max-write-level max-write-length)
(let ((port (repl-output-port)))
(output-port-readtable-set!
port
(let* ((rt (output-port-readtable port))
(rt (readtable-sharing-allowed?-set rt sharing-allowed?))
(rt (readtable-max-write-level-set rt max-write-level))
(rt (readtable-max-write-length-set rt max-write-length)))
rt))))
(repl-ctrl #t 2 5)
It is convenient to place this code in the ~/gambcini.scm file so
that it does not have to be entered each time gsi is invoked.
The above code will use the SRFI 38 syntax for shared/circular
structures. It will also stop printing parts of a structure that are
beyond a nesting level of 2, or beyond a length of 5 (using an
elipsis instead).
Marc
More information about the Gambit-list
mailing list