> On Aug 10, 2016, at 4:53 AM, Delphine Demange <delphine.dema...@gmail.com> > wrote: > > Hi, > > Just for the sake of completeness. > > In constructor-style-print.rkt, I've switched on the printing of booleans as > "true" and "false" as follows (editing line 14): > > ;; print-convert/constructor-style : Any -> Any > (define (print-convert/constructor-style v) > (parameterize ([constructor-style-printing #true] > [booleans-as-true/false #true]) > (print-convert v)))
Yes, DrRacket's "constructor" mode does this. This code was based on the teaching languages though, and the teaching languages set `booleans-as-true/false` to false here: https://github.com/racket/htdp/blob/master/htdp-lib/htdp/bsl/runtime.rkt#L15 Neither one is really more "constructor"-y than the other. > and also turned a write into a pretty-write at line 24, so that a newline is > printed after each value: > ;; constructor-style-print : Any [Output-Port] [(U 0 1)] -> Void > ;; Prints v using constructor-style printing (without pretty-printing). > (define (constructor-style-print v [out (current-output-port)] [qdepth 0]) > (parameterize ([print-reader-abbreviations #true]) > (pretty-write (print-convert/constructor-style v) out))) The `constructor-style-print` function isn't supposed to add a newline. I added a `constructor-style-println` function that does pretty-print it though, with the newline: https://github.com/AlexKnauth/quote-bad/blob/master/constructor-style-print/constructor-style-print.rkt#L26-L31 At one point I had a pull request to allow pretty-printing without newlines at the end, but I had forgotten about it. https://github.com/racket/racket/pull/1137 I need to update it and change it to add a keyword argument to each function. Then `constructor-style-print` could pretty-print it without needing the newline. Alex Knauth > This is closer to the behavior of drracket's constructor style printing. > Maybe there are better ways to achieve the same result, though. > > Best, > Delphine -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.