From 679b2d3872acbc33af9e0e749c2a103164670416 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Tue, 7 Feb 2012 04:41:47 -0700 Subject: [PATCH] lazy-require: use cm-accomplice --- collects/unstable/lazy-require.rkt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/collects/unstable/lazy-require.rkt b/collects/unstable/lazy-require.rkt index e4605dcbdc..f7e1934a89 100644 --- a/collects/unstable/lazy-require.rkt +++ b/collects/unstable/lazy-require.rkt @@ -1,5 +1,6 @@ #lang racket/base -(require (for-syntax racket/base) +(require (for-syntax racket/base + compiler/cm-accomplice) racket/runtime-path racket/promise) (provide lazy-require) @@ -28,6 +29,9 @@ ;; implicit quasiquote, so can use normal module-path syntax ;; or escape to compute a the module-path via expression #'(begin (define-runtime-module-path-index mpi-var (quasiquote modpath)) + (define-values () + (let-syntax ([_ (do-registration (#%variable-reference) (quasiquote modpath))]) + (values))) (define (get-sym sym) (parameterize ((current-namespace (namespace-anchor->namespace anchor))) (dynamic-require mpi-var sym))) @@ -42,3 +46,13 @@ (lambda (kws kwargs . args) (keyword-apply (force fun-p) kws kwargs args))) name))) + +(begin-for-syntax + (define (do-registration vr modpath) + (let ([path (resolved-module-path-name + (module-path-index-resolve + (module-path-index-join + modpath + (variable-reference->resolved-module-path vr))))]) + (when (path? path) + (register-external-file path)))))