Re: [racket-users] difference in struct printing from default #:transparent versus make-constructor-style-printer

2020-09-03 Thread Jeremy Siek
of Int2 and Prim2, your program should produce the > output you expect. I'll add a note to the docs for > make-constructor-style-printer. > > Ryan > > > On Wed, Sep 2, 2020 at 10:07 PM Jeremy Siek wrote: > >> I'm seeing some bad behavior from make-cons

[racket-users] difference in struct printing from default #:transparent versus make-constructor-style-printer

2020-09-02 Thread Jeremy Siek
I'm seeing some bad behavior from make-constructor-style-printer when there are lists mixed in with the structs. It seems to switch from print mode to write mode when going under a list. Whereas the default printer for transparent structs gets this right. The following program demonstrates the d

[racket-users] Re: Pretty Printing for ASTs represented as structs

2020-08-17 Thread Jeremy Siek
Thanks for the tip! I found the following to work pretty well :) #lang racket (require racket/match) (require racket/struct) (struct Var (name) #:methods gen:custom-write [(define (write-proc ast port mode) (match ast [(Var x) (write x port)]))]) (struct Num (value)

[racket-users] Pretty Printing for ASTs represented as structs

2020-08-16 Thread Jeremy Siek
Hi All, I'm looking into using Racket structs to represent abstract syntax trees. I've gotten as far as defining gen:custom-write properties, but have not yet figured out how to control indenting. Also, I'm not sure I'm just calling write-string, write, and newline in my gen:custom-write methods