[racket] Changing the pretty print columns when running raco expand

25 views
Skip to first unread message

Eric Dobson

unread,
Nov 7, 2013, 11:39:41 AM11/7/13
to us...@racket-lang.org
I use raco expand a bunch when debugging macros to see the final
output and see why it doesn't match up with my expectations. One issue
I have is that the pretty printer decides to only use 80ish columns
when my terminal is 200 wide, this makes the output really ugly and
hard to read. If this was a racket command I could use -e
"(pretty-print-colums 200)", but I don't see a way to do that with
raco. Is there an easy way to set up printing parameters before the
expansion code is run?
____________________
Racket Users list:
http://lists.racket-lang.org/users

Neil Van Dyke

unread,
Nov 7, 2013, 12:13:58 PM11/7/13
to Eric Dobson, us...@racket-lang.org
"raco expand"? If you've not yet tried the Macro Stepper feature of
DrRacket, you are in for a treat.

Racket's theoretical foundation for phases, Racket's syntax objects,
"syntax-parse", DrRacket's Macro Stepper, and DrRacket's online Check
Syntax (on-the-fly error highlighting when people are using the macros,
especially good if you used "syntax-parse")... these are some of the
reasons that Racket slaughters at mini-languages and DSLs. I suggest
that people look at any of these that they have not already.

BTW, one of the tricks to using the Macro Stepper quickly: put your
example use of the macro in its own module temporarily, with as little
other stuff as possible. Fewer clicks of the stepper button to expand
what you're interested in.

Neil V.

Konrad Hinsen

unread,
Nov 7, 2013, 12:28:35 PM11/7/13
to us...@racket-lang.org
Neil Van Dyke writes:

> "raco expand"? If you've not yet tried the Macro Stepper feature of
> DrRacket, you are in for a treat.

And for Emacs fans, Geiser provides macro-expansion-at-a-keypress.

Konrad.

Eric Dobson

unread,
Nov 7, 2013, 1:00:23 PM11/7/13
to Konrad Hinsen, us...@racket-lang.org
I know about the macro stepper and it doesn't work for my use case. I
don't have a simple macro, I have the entire TR typechecker/optimizer.
Thus splitting it out into its own module is not feasible. Also
because of how TR works there is one major macro application and the
macro stepper cannot see into that.

The use case I have is, Take TR program that is being misoptimized,
look at the fully expanded syntax and see what went wrong. Thus the
thing I need is a good visualization of the fully expanded syntax. The
macro stepper may give a slightly more annotated version than 'raco
expand' but those annotations are unnecessary for what I need. TR's
optimizer is good at using generate-temporary so that you don't need
the mark numbers to follow bindings. Also using the macro stepper
requires using DrRacket, which has issues when I change its
dependencies (TR) out from underneath it and is less keyboard/screen
realestate friendly then my terminal.

Matthew Flatt

unread,
Nov 7, 2013, 5:39:57 PM11/7/13
to Eric Dobson, us...@racket-lang.org
At Thu, 7 Nov 2013 08:39:41 -0800, Eric Dobson wrote:
> I use raco expand a bunch when debugging macros to see the final
> output and see why it doesn't match up with my expectations. One issue
> I have is that the pretty printer decides to only use 80ish columns
> when my terminal is 200 wide, this makes the output really ugly and
> hard to read. If this was a racket command I could use -e
> "(pretty-print-colums 200)", but I don't see a way to do that with
> raco. Is there an easy way to set up printing parameters before the
> expansion code is run?

I've added a `--columns <n>` (shorthand `-n <n>`) argument to `raco
expand` and `raco decompile`.
Reply all
Reply to author
Forward
0 new messages