On Fri, Oct 31, 2014 at 5:57 AM, Konrad Hinsen <konrad.hin...@fastmail.net> wrote: > Sam Tobin-Hochstadt writes: > > > The rule is that for anything like: > > > > (module m lang > > (form ...)) > > > > `form` is expanded until it either produces `#%plain-module-begin` or > > another core form. In the former case, it just continues, in the > > latter case, it wraps the whole thing with `#%module-begin` as > > exported from the specified language, and then expands that. > > > > In your particular example, it will expand (displayln (foo 42)) to > > (#%app displayln (foo 42)) and then to (#%module-begin (#%app > > displayln (foo 42))). > > > > > Are they part of the language definition? More specifically, I am > > > looking for a way to override them. > > > > I'm not sure exactly what you want to override here. > > Whatever it takes to prevent the partial expansion to end in > #%plain-module-begin. I just want to get rid of the special treatment > for single-form modules. For my mini-language, I expect single-form > modules to be frequent special cases. Right now they fail > systematically because of the special treatment.
You can't turn this feature off -- it's a fundamental part of the macro system. There are a few strategies that you can employ here: 1. If your language is written with #lang, then you can insert, at `read` time, an extra form, perhaps just `(begin)`. Then all your modules will have at least two forms. 2. You can also, in the #lang case, `read` directly to `#%module-begin` wrapped around everything, which will mean that your #%module-begin gets control right away. 3. You could change the bindings of some of your exports, such as #%app or anything else that might appear as the head form in a single body expression, to check for (syntax-local-context) begin 'module-begin, and then behaving differently -- perhaps wrapping in #%expression or in #%module-begin. Hopefully one of those will work for you. Sam ____________________ Racket Users list: http://lists.racket-lang.org/users