Closed jackfirth closed 8 years ago
I don't really like the idea of a define-lang-syntax
form expanding to a submodule, but if syntax/lang
(or a similar thing) could be a module language for the same purpose, that would be awesome.
I'm thinking of something like this:
(module reader syntax/lang reprovide reprovide)
Instead of this:
(define-lang-syntax reprovide reprovide)
That way it's obvious that it's a reader submodule.
Also I feel like syntax/lang
should be reserved for something more general instead of something this specific. Would syntax/macro-lang
be clearer? Since it takes the module body and treats it as the input to the reprovide
macro?
(module reader syntax/macro-lang reprovide reprovide)
I just realized my suggestion wouldn't allow reprovide
to be used as a module language. So would this work:
reprovide/main.rkt
#lang s-exp syntax/macro-lang reprovide reprovide
(require reprovide/reprovide)
(provide #%datum ...)
As equivalent to:
#lang racket/base
(require reprovide/reprovide)
(provide #%datum ...)
(provide (rename-out [new-module-begin #%module-begin]))
(define-syntax-rule (new-module-begin module-body (... ...))
(#%module-begin (reprovide module-body (... ...))))
(module reader syntax/module-reader reprovide)
Would that be a better solution?
I just did that with https://github.com/AlexKnauth/syntax-macro-lang
Yes, that's much better and one of the ideas I had for something to build on top of the syntax-lang package.
This PR uses a new library I made,
syntax-lang
, to simplify the implementation of the language.define-lang-syntax
uses reader submodules andsyntax/module-reader
to create a new#lang
from a given macro, similar tosyntax/module-reader
. Reader submodules let it keep all the code for reading and expanding in the same file. For details of how that works, see the submodules blog post. (I couldn't find anything in the docs about reader submodules, as far as I know they're only mentioned in that blog post.)This is mostly a test of the library, let me know what you think.