add macrology for caching submodule

pull/84/head
Matthew Butterick 9 years ago
parent a854844ae6
commit 1fde2db75e

@ -1,6 +1,20 @@
#lang racket/base #lang racket/base
(require (for-syntax racket/base racket/syntax))
(provide (all-defined-out)) (provide (all-defined-out))
(define-syntax (define-caching-ns stx)
(syntax-case stx ()
[(_ name)
(with-syntax ([caching-module-name (generate-temporary)]
[NS-NAME (format-id stx "~a" #'name)])
#'(begin
(module caching-module-name racket/base
(define-namespace-anchor nsa) ; could handle this macro-introduced name better
(provide nsa))
(require 'caching-module-name)
(define NS-NAME (namespace-anchor->namespace nsa))))]))
(define (load-in-namespace to-ns . module-names) (define (load-in-namespace to-ns . module-names)
(for-each (λ(mn) (eval `(require ,mn) to-ns)) module-names)) (for-each (λ(mn) (eval `(require ,mn) to-ns)) module-names))

@ -38,15 +38,8 @@
(and directory-require-files (map dynamic-rerequire directory-require-files)) (and directory-require-files (map dynamic-rerequire directory-require-files))
(void)) (void))
(require sugar/debug)
;; set up namespace for module caching ;; set up namespace for module caching
(module caching-module racket/base (define-caching-ns caching-module-ns)
(define-namespace-anchor caching-module-nsa)
(provide caching-module-nsa))
(require 'caching-module)
(define caching-module-ns (namespace-anchor->namespace caching-module-nsa))
(define cached-module-names '(xml (define cached-module-names '(xml
racket/bool racket/bool
racket/class racket/class
@ -76,7 +69,7 @@
sugar sugar
txexpr)) txexpr))
(apply load-in-namespace caching-module-ns cached-module-names)
(define (path->hash path subkey) (define (path->hash path subkey)
(dynamic-rerequire path) (dynamic-rerequire path)

@ -224,12 +224,7 @@
;; set up namespace for module caching ;; set up namespace for module caching
(module caching-module racket/base (define-caching-ns caching-module-ns)
(define-namespace-anchor caching-module-nsa)
(provide caching-module-nsa))
(require 'caching-module)
(define caching-module-ns (namespace-anchor->namespace caching-module-nsa))
(define cached-module-names '(xml (define cached-module-names '(xml
racket/bool racket/bool
racket/class racket/class

Loading…
Cancel
Save