[racket] requiring in multiple phases

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Mon May 21 13:39:19 EDT 2012

If I want to "require" a module for multiple phases, is there a shortcut 
for that?

For example, right now, I have this in a real-world file:

(require (for-syntax racket/base
                      syntax/parse
                      "html-template-generate.rkt"
                      "html-template-parse.rkt"
                      "planet-neil-html-writing.rkt")
          (for-template "html-template-generate.rkt"
                        "html-template-parse.rkt"
                        "planet-neil-html-writing.rkt")
          syntax/parse
          "html-template-generate.rkt"
          "html-template-parse.rkt"
          "planet-neil-html-writing.rkt"
          "planet-neil-mcfly.rkt")

I would prefer less duplicated text for modules that I know I need to 
"require" 3 different ways:

(require (for-darned-near-every-phase "html-template-generate.rkt"
                                       "html-template-parse.rkt"
                                       "planet-neil-html-writing.rkt")
          (for-syntax racket/base
                      syntax/parse)
          syntax/parse
          "planet-neil-mcfly.rkt")

Unless I'm doing something wrong, needing a module 3 different ways 
doesn't seem too unusual with the new-fangled syntax transformers.

(I don't know whether I'll need quite as many "require"s once submodules 
make it into the Racket release.)

Neil V.


Posted on the users mailing list.