[racket] Changing at-expressions to other-glyph-expressions
20 minutes ago, Matthew Flatt wrote:
> At Fri, 19 Apr 2013 16:42:40 -0700, Matthew Butterick wrote:
> > Thanks. Yes, I did see that in the docs. The problem with this technique is
> > that once I wrap the input text in @list| (or @list|^, or ... etc.) to get
> > the benefit of @-escaping, then I lose the ability to do defines within the
> > body of that text. (Throws error "define not allowed in expression
> > context.")
>
> You could use `begin' instead of list:
>
> #lang scribble/base
>
> @; Everything within the following will be escaped. Use |^ to unescape.
> @begin|^{
>
> this is an example with @ signs in it.
>
> |^@(define x "at")
>
> @ is |^@x
>
> }^|
In the `scribble/text' language (which I think is what Butterick
uses), the right thing to use is `begin/text', which is kind of like
`list' but it allows definitions:
#lang at-exp racket
(require scribble/text)
(output @begin/text{foo
@(define bar "blah")
@bar})
Alternatively, when `scribble/text' is used as a language, the binding
is `text':
#lang scribble/text
@(define x @text{foo
@(define bar "blah")
@bar})
@x
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://barzilay.org/ Maze is Life!