remove implicit quasiquote from lazy-require
This commit is contained in:
parent
fd7d8a412c
commit
3075b4d285
|
@ -7,21 +7,14 @@
|
||||||
|
|
||||||
(define-syntax (lazy-require stx)
|
(define-syntax (lazy-require stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(lazy-require #:requires-for-path (extra-req ...)
|
|
||||||
[modpath (thing ...)] ...)
|
|
||||||
#`(begin
|
|
||||||
(lazy-require1 modpath (extra-req ...) (thing ...) #,stx)
|
|
||||||
...)]
|
|
||||||
[(lazy-require [modpath (thing ...)] ...)
|
[(lazy-require [modpath (thing ...)] ...)
|
||||||
(syntax/loc stx
|
#`(begin (lazy-require1 modpath (thing ...) #,stx) ...)]))
|
||||||
(lazy-require #:requires-for-path ()
|
|
||||||
[modpath (thing ...)] ...))]))
|
|
||||||
|
|
||||||
(define-for-syntax counter 0)
|
(define-for-syntax counter 0)
|
||||||
|
|
||||||
(define-syntax (lazy-require1 stx)
|
(define-syntax (lazy-require1 stx)
|
||||||
(syntax-case stx ()
|
(syntax-case stx ()
|
||||||
[(lazy-require1 modpath (extra-req ...) (name ...) orig-stx)
|
[(lazy-require1 modpath (name ...) orig-stx)
|
||||||
(with-syntax ([(defn ...)
|
(with-syntax ([(defn ...)
|
||||||
(for/list ([name (in-list (syntax->list #'(name ...)))])
|
(for/list ([name (in-list (syntax->list #'(name ...)))])
|
||||||
(unless (identifier? name)
|
(unless (identifier? name)
|
||||||
|
@ -37,7 +30,7 @@
|
||||||
(let ([phase (sub1 (variable-reference->phase (#%variable-reference)))])
|
(let ([phase (sub1 (variable-reference->phase (#%variable-reference)))])
|
||||||
(if (zero? phase)
|
(if (zero? phase)
|
||||||
;; `define-runtime-module-path-index' works right at phase-level 0:
|
;; `define-runtime-module-path-index' works right at phase-level 0:
|
||||||
#'(define-runtime-module-path-index mpi-var (quasiquote modpath))
|
#'(define-runtime-module-path-index mpi-var (quote modpath))
|
||||||
;; need a submodule:
|
;; need a submodule:
|
||||||
(with-syntax ([lazy-require-path-n
|
(with-syntax ([lazy-require-path-n
|
||||||
(string->symbol
|
(string->symbol
|
||||||
|
@ -48,20 +41,17 @@
|
||||||
#'(begin
|
#'(begin
|
||||||
(module lazy-require-path-n racket/base
|
(module lazy-require-path-n racket/base
|
||||||
(require racket/runtime-path
|
(require racket/runtime-path
|
||||||
(for-syntax racket/base)
|
(for-syntax racket/base))
|
||||||
extra-req ...)
|
|
||||||
(provide mpi-var)
|
(provide mpi-var)
|
||||||
(define-runtime-module-path-index mpi-var (quasiquote modpath)))
|
(define-runtime-module-path-index mpi-var (quote modpath)))
|
||||||
(require 'lazy-require-path-n)))))])
|
(require 'lazy-require-path-n)))))])
|
||||||
;; implicit quasiquote, so can use normal module-path syntax
|
|
||||||
;; or escape to compute a the module-path via expression
|
|
||||||
#'(begin
|
#'(begin
|
||||||
define-mpi-var
|
define-mpi-var
|
||||||
(define (get-sym sym)
|
(define (get-sym sym)
|
||||||
(parameterize ((current-namespace (variable-reference->namespace (#%variable-reference))))
|
(parameterize ((current-namespace (variable-reference->namespace (#%variable-reference))))
|
||||||
(begin0
|
(begin0
|
||||||
(dynamic-require mpi-var sym)
|
(dynamic-require mpi-var sym)
|
||||||
(do-registration (#%variable-reference) (quasiquote modpath)))))
|
(do-registration (#%variable-reference) (quote modpath)))))
|
||||||
defn ...))]))
|
defn ...))]))
|
||||||
|
|
||||||
(define (make-lazy-function name get-sym)
|
(define (make-lazy-function name get-sym)
|
||||||
|
|
|
@ -2786,33 +2786,17 @@ Attaches a @racket['compiler-hint:cross-module-inline]
|
||||||
|
|
||||||
@note-lib-only[racket/lazy-require]
|
@note-lib-only[racket/lazy-require]
|
||||||
|
|
||||||
@defform/subs[#:literals (unquote)
|
@defform[(lazy-require [module-path (imported-fun-id ...)] ...)]{
|
||||||
(lazy-require maybe-requires
|
|
||||||
[mod (imported-fun-id ...)] ...)
|
|
||||||
([mod module-path
|
|
||||||
(unquote module-path-expr)]
|
|
||||||
[maybe-requires code:blank
|
|
||||||
(code:line #:requires-for-path (require-spec ...))])
|
|
||||||
#:contracts ([module-path-expr module-path?])]{
|
|
||||||
|
|
||||||
Defines each @racket[imported-fun-id] as a function that, when called,
|
Defines each @racket[imported-fun-id] as a function that, when called,
|
||||||
dynamically requires the export named @racket[imported-fun-id] from
|
dynamically requires the export named @racket[imported-fun-id] from
|
||||||
the module specified by @racket[mod] and calls it with the same
|
the module specified by @racket[module-path] and calls it with the
|
||||||
arguments.
|
same arguments.
|
||||||
|
|
||||||
The module @racket[mod] can be specified as a @racket[_module-path]
|
|
||||||
(see @racket[require]) or as an @racket[unquote]-escaped expression
|
|
||||||
that computes a module path. As with
|
|
||||||
@racket[define-runtime-module-path-index], a @racket[module-path-expr]
|
|
||||||
is evaluated both in phase level 0 and phase level 1 relative to its
|
|
||||||
enclosing phase level.
|
|
||||||
|
|
||||||
If the enclosing relative phase level is not 0, then
|
If the enclosing relative phase level is not 0, then
|
||||||
@racket[module-path-expr] is also placed in a submodule (with a use of
|
@racket[module-path] is also placed in a submodule (with a use of
|
||||||
@racket[define-runtime-module-path-index] at phase level 0 within the
|
@racket[define-runtime-module-path-index] at phase level 0 within the
|
||||||
submodule); supply extra @racket[require-spec]s with
|
submodule). Introduced submodules have the names
|
||||||
@racket[#:requires-for-path] to bind within the submodule for
|
|
||||||
@racket[module-path-expr]. Introduced submodules have the names
|
|
||||||
@racket[lazy-require-]@racket[_n]@racketidfont{-}@racket[_m], where
|
@racket[lazy-require-]@racket[_n]@racketidfont{-}@racket[_m], where
|
||||||
@racket[_n] is a phase-level number and @racket[_m] is a number.
|
@racket[_n] is a phase-level number and @racket[_m] is a number.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user