I'm trying to implement a custom writer for a struct with generics, but I think I'm misunderstanding something.
What I want to do is specialize only the behavior for `write' and `display', but leave the behavior for `print' untouched. So I thought that is what define/generic was for, but the following loops indefinitely: #lang racket (require racket/generic) (struct A (x y) #:transparent #:methods gen:custom-write [(define/generic super-write write-proc) (define (write-proc a port mode) (case mode [(#t) (write (list (A-x a) (A-y a)) port)] [(#f) (display (list (A-x a) (A-y a)) port)] [else (super-write a port mode)]))]) (define a (A 1 'b)) (displayln a) ; ok (write a)(newline) ; ok (print a)(newline) ; infinite loop What's the correct way to do that then? Thanks, Laurent
____________________ Racket Users list: http://lists.racket-lang.org/users