[plt-scheme] Pretty printing structs

From: Paulo J. Matos (pocm at mega.ist.utl.pt)
Date: Sun Sep 29 13:34:04 EDT 2002

Hi all,

I'd like to pretty print a structure so that any call to
some function that will print the object anywhere will print it
in a given format. I've tried:
(require (lib "pretty.ss"))

(define-struct point (x y))

(define print-point
  (lambda (point)
    (format port "x: ~a, y: ~a" (point-x point)
            (point-y point))))

(current-print print-point)
(define p1 (make-point 2 3))
(display p1)

But it is not working. I expected:
x: 2, y: 3

Any ideas?

Best regards,

Paulo J. Matos : pocm(_at_)mega.ist.utl.pt
Instituto Superior Tecnico - Lisbon
Software & Computer Engineering - A.I.
 - > http://mega.ist.utl.pt/~pocm
	Yes, God had a deadline...
		So, He wrote it all in Lisp!

Posted on the users mailing list.