On Wed, Sep 30, 2015 at 1:54 PM, Greg Hendershott <greghendersh...@gmail.com> wrote: > So a kind of pretty-printing for at-expressions? > > I'm not aware of an existing procedure to do this.
When I wrote about the reader implementation, I did it with a cute hack that: * Uses backslash as the command character instead of @ * Uses a language that extends scribble/text by making unknown backslashed forms print themselves out * Pipe the result into latex The result of that is a combination of latex and racket: some random \foo[bar]{baz} would spit itself out if `foo` is not defined, but if you do define it, then it's the usual application of a function -- so you can define some commands in latex, and other commands in racket. The interesting bit is the second bullet which is doing, IIUC, roughly what Neil wants and you try to do. I looked at the code at some point, and it's not too good enough to just put out (mostly due to its age), but if you're interested (Neil) I can send you the whole thing. In any case, one major comment: > (define (print/at-exp stx-or-sepxr) > (match stx-or-sepxr > [(? syntax? stx) (print/at-exp (syntax->datum stx))] That's a major mistake! The reader puts useful information in the syntax properties. It should tell you how what is a scribble form (so you don't transform everything), and many expressions are in the datum part. Without that, I'm guessing this code will break with common expressions that look like @foo[#:bar "baz"]{blah}. The strings also have useful properties that identify newlines and indentation. There's not enough to reconstruct the original source completely though -- but if the forms come from an existing file, then I think that the best way to hack that is to use the source information and just read the contents of the file. (A bad hack that might lead to a better way to do whatever, something that doesn't require copying source code...) -- ((x=>x(x))(x=>x(x))) Eli Barzilay: http://barzilay.org/ Maze is Life! -- 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.