remove implicit quasiquote from lazy-require
This commit is contained in:
parent
fd7d8a412c
commit
3075b4d285
|
@ -7,21 +7,14 @@
|
|||
|
||||
(define-syntax (lazy-require 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 ...)] ...)
|
||||
(syntax/loc stx
|
||||
(lazy-require #:requires-for-path ()
|
||||
[modpath (thing ...)] ...))]))
|
||||
#`(begin (lazy-require1 modpath (thing ...) #,stx) ...)]))
|
||||
|
||||
(define-for-syntax counter 0)
|
||||
|
||||
(define-syntax (lazy-require1 stx)
|
||||
(syntax-case stx ()
|
||||
[(lazy-require1 modpath (extra-req ...) (name ...) orig-stx)
|
||||
[(lazy-require1 modpath (name ...) orig-stx)
|
||||
(with-syntax ([(defn ...)
|
||||
(for/list ([name (in-list (syntax->list #'(name ...)))])
|
||||
(unless (identifier? name)
|
||||
|
@ -37,7 +30,7 @@
|
|||
(let ([phase (sub1 (variable-reference->phase (#%variable-reference)))])
|
||||
(if (zero? phase)
|
||||
;; `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:
|
||||
(with-syntax ([lazy-require-path-n
|
||||
(string->symbol
|
||||
|
@ -48,20 +41,17 @@
|
|||
#'(begin
|
||||
(module lazy-require-path-n racket/base
|
||||
(require racket/runtime-path
|
||||
(for-syntax racket/base)
|
||||
extra-req ...)
|
||||
(for-syntax racket/base))
|
||||
(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)))))])
|
||||
;; implicit quasiquote, so can use normal module-path syntax
|
||||
;; or escape to compute a the module-path via expression
|
||||
#'(begin
|
||||
define-mpi-var
|
||||
(define (get-sym sym)
|
||||
(parameterize ((current-namespace (variable-reference->namespace (#%variable-reference))))
|
||||
(begin0
|
||||
(dynamic-require mpi-var sym)
|
||||
(do-registration (#%variable-reference) (quasiquote modpath)))))
|
||||
(do-registration (#%variable-reference) (quote modpath)))))
|
||||
defn ...))]))
|
||||
|
||||
(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]
|
||||
|
||||
@defform/subs[#:literals (unquote)
|
||||
(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?])]{
|
||||
@defform[(lazy-require [module-path (imported-fun-id ...)] ...)]{
|
||||
|
||||
Defines each @racket[imported-fun-id] as a function that, when called,
|
||||
dynamically requires the export named @racket[imported-fun-id] from
|
||||
the module specified by @racket[mod] and calls it with the 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.
|
||||
the module specified by @racket[module-path] and calls it with the
|
||||
same arguments.
|
||||
|
||||
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
|
||||
submodule); supply extra @racket[require-spec]s with
|
||||
@racket[#:requires-for-path] to bind within the submodule for
|
||||
@racket[module-path-expr]. Introduced submodules have the names
|
||||
submodule). Introduced submodules have the names
|
||||
@racket[lazy-require-]@racket[_n]@racketidfont{-}@racket[_m], where
|
||||
@racket[_n] is a phase-level number and @racket[_m] is a number.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user