Although it's an old library, you can use
`construction-style-printing` and `mzlib/pconvert` to get this effect.
Take the following module:
#lang racket
(require mzlib/pconvert)
(global-port-print-handler
(λ (data output [quote-level 0])
(parameterize ([current-output-port output]
[constructor-style-printing #t])
(write (print-convert data)))))
'(1 . 2)
When evaluated, it prints out: "(cons 1 2)"
~Leif Andersen
On Mon, May 30, 2016 at 11:31 AM, Alex Knauth <[email protected]> wrote:
> Hello,
>
> DrRacket has a setting that allows me to change the printing style between
> four choices: print, constructor, quasiquote, and write.
>
> Is there a way to turn on constructor-style printing outside of DrRacket?
>
> If there isn't a simple way to do this, should a simple way be added to
> racket?
>
> Something like:
>
> > (global-port-print-handler constructor-style-printer)
> > (list 1 2 (+ 1 2))
> (list 1 2 3)
> > (vector-immutable 1 2 (+ 1 2))
> (vector-immutable 1 2 3)
>
> I'm mainly trying to avoid `quote` appearing in printouts, and I'm also
> trying to avoid literals that implicitly quote their sub-expressions, such as
> vector literals. I'm trying to make those print as uses of functions like
> `list`, `vector-immutable`, etc.
>
> DrRacket's options for the printing style are described here:
> http://docs.racket-lang.org/drracket/output-syntax.html
>
> And DrRacket sets the `global-port-print-handler` parameter here:
> https://github.com/racket/drracket/blob/master/drracket/drracket/private/language.rkt#L602
>
> Alex Knauth
>
>
> --
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.