[racket] Can a #reader be used with (module ...) ?
There's not currently anything like `#reader` that would hide a closing
parenthesis from the reader.
I think you could make a new reader that recurs to `read` with an input
port that stops consuming input from the original just before a closing
parenthesis followed by an EOF --- maybe by peeking at all the input to
determine a length to pass to `call-with-limited-input-port`. Assuming
that the new reader is in `with-limited-port`, then
#lang racket/base
(module inner racket/base
'#reader with-limited-port
#reader (submod pollen/main reader)
Hello World
)
could work. Or you could build that port-limiting approach into a new
reader in a `limited-reader` submodule that always chains to the
sibling `reader` submodule:
#lang racket/base
(module inner racket/base
'#reader(submod pollen/main limited-reader)Hello World
)
At Mon, 15 Sep 2014 13:38:00 -0700, Matthew Butterick wrote:
> I'm aware that `#lang name ...` is equivalent to `(module id name ...)`.
> But `#lang` automatically picks up a reader; `module` does not.
>
> Is there a way to attach a reader to the `module` form (the idea being
> that then, within the `module` expression, you could write using the
> native syntax of the #lang)?
>
> Studying the example in reader extensions (Guide § 17.2), I found that
> this works, but I haven't figured out if it can be generalized:
>
> #lang racket/base
> (module inner racket/base
> '(#reader"five.rkt"23456))
> (require 'inner)
>
> For instance, my current reader works in the REPL, like so:
>
> '#reader(submod pollen/main reader)Hello World
>
> But this doesn't work, because the reader, which operates in text mode,
> absorbs the closing parenthesis:
>
> #lang racket/base
> (module inner racket/base
> '#reader(submod pollen/main reader)Hello World
> )
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users