The readtables doc is a bit over my head. Do readtables allow me to define how the system will display a type I create? For example, something like:
(set 1 2 'pi)
{1 2 pi}
(dict 'grass 'green 'sky 'blue 'v8 'red)
[grass => green sky => blue v8 => red]
If not, is such a thing possible through some other means, in gambit?
On 8/6/07, Marc Feeley feeley@iro.umontreal.ca wrote:
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
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list