There might be a better way, but I'd probably make a language for writing
this kind of module, in the spirit of `#lang syntax/module-reader`, where
its `#%module-begin` would expect the module body to be `<THE ONLY PART
THAT CHANGES>`, similar to the way that the body of `(module reader
syntax/module-reader my-language-implementation-module)` is a module name.

-Philip


On Mon, Aug 31, 2020 at 1:24 PM Hendrik Boom <hend...@topoi.pooq.com> wrote:

> On Mon, Aug 31, 2020 at 10:06:42AM -0700, Shriram Krishnamurthi wrote:
> > I'm having some trouble abstracting over this code. Any suggestions?
> >
> > I have numerous files that follow this boilerplate:
> >
> > #lang racket
> >
> > (require <LIBRARY FILE>)
> >
> > (provide (rename-out [mod-begin #%module-begin]
> >                      [ti        #%top-interaction]))
> >
> > (define-values (namespaces lang-print-names)
> >   <THE ONLY PART THAT CHANGES>)
> >
> > (define-syntax (multi-runner stx)
> >   (syntax-case stx (TEST)
> >     [(_ (TEST e r ...))
> >      #`(test-output 'e (list 'r ...) namespaces)]
> >     [(_ e)
> >      #`(show-output 'e namespaces lang-print-names)]))
> >
> > (define-syntax mod-begin
> >   (λ (stx)
> >     (syntax-case stx ()
> >       [(_ b ...)
> >        #'(#%printing-module-begin (multi-runner b) ...)])))
> >
> > (define-syntax ti
> >   (λ (stx)
> >     (syntax-case stx ()
> >       ([_ . e]
> >        #'(#%top-interaction . (multi-runner e))))))
> >
> > I've abstract most of the details into `test-output` and `show-output`
> into
> > <LIBRARY FILE>. I would ideally like to move as much of what's left as
> > possible into the same file.
> >
> > The key problem is that the MB and TI depend on `multi-runner`, which in
> > turn depends on `namespaces`, which is a name at run time. As long as
> > everything is in the same module, no problem. But when I start to move
> the
> > boilerplate out…
> >
> > Concrete suggestions welcome — I've tried several different things
> (various
> > forms of abstraction, syntax parameters, etc.) without luck.
>
> Maybe a macro or two?  Perhaps a nonhygienic one?
>
> -- hendrik
>
> >
> > Thanks,
> > Shriram
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/362f807e-3561-4be6-8b4d-937776fea36bn%40googlegroups.com
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200831172435.6f6oweyhxjux4g5j%40topoi.pooq.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/010001744593f3c3-1bc786d7-6d32-4e00-ab62-7d3ad7a42359-000000%40email.amazonses.com.

Reply via email to