[racket] Provide transformers

From: Spencer florence (spencerflorence at gmail.com)
Date: Sun Sep 21 12:21:44 EDT 2014

I think the way i have seen this done is to use a macro at the top level instead of a provide transformer.




for example define/provide-test-suite from rackunit probably works a little like




(define/provide-test-suite tests blah blah …)




=>




(begin 

   (provide tests)

   (define tests (test-suite blah blah blah …))







So maybe you could make a provide/test-pred form?

On Fri, Sep 19, 2014 at 4:42 PM, Jack Firth <jackhfirth at gmail.com> wrote:

> I've been looking into how to design a macro that would specify tests in a
> provide transformer, for example something like
>     (provide (test-pred-out some-integer integer?))
> I'd like that to expand to:
>     (provide some-integer)
>     (module+ test
>       (check-pred integer? some-integer))
> From what I can gather from the reference, normally provide forms are done
> with define-provide-syntax, but that macro doesn't let me splice anything
> into the module body. The reference mentions provide pre-transformers, and
> says:
> "A provide pre-transformer is applied as part of the first phase of a
> module’s expansion. Since it is used in the first phase, a provide
> pre-transformer can use functions such as syntax-local-lift-expression to
> introduce expressions and definitions in the enclosing module."
> So it sounds like what I want is definitely possible, but I have no idea
> how to actually *do* it. Does anyone have some simple well-explained
> examples to guide me in the right direction?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140921/620eb4f8/attachment.html>

Posted on the users mailing list.