[racket] abstracting over codeblock

From: Eli Barzilay (eli at barzilay.org)
Date: Thu Sep 8 21:03:11 EDT 2011

40 minutes ago, Shriram Krishnamurthi wrote:
> I'm trying to convert some old slatex'ed documents into scribble and
> running into trouble.  I don't seem to have a clear enough handle on
> how to use codeblock.
> I can, for instance, convert
>   \begin{schemedisplay}
>   foo
>   bar
>   \end{schemedisplay}
> into
>   @mycode{
>   foo
>   bar
>   }
> where
>   @(define(mycode . terms) (apply verbatim terms))
> works fine.  However, codeblock is syntax, not a function, so I can't
> just replace "verbatim" with "codeblock" above.  [...]

Using curly braces means that you're writing strings, in this case,
that's the same as:

  @(mycode "foo" "\n" "bar")

This works fine with functions like `vebatim' that expect strings as
their input.  Since `codeblock' expects code, and it's a macro that
does the quoting itself, then you'd need a macro to use it.  For

  @(define-syntax-rule (mycode code ...) (codeblock code ...))

The square brackets means that the body is read in "datum mode", using
plain sexpr syntax.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the users mailing list.