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.

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.

Reply via email to