define-runtime-module-path
svn: r13283
This commit is contained in:
parent
134138916f
commit
5e2dfcbac4
|
@ -3,6 +3,32 @@
|
|||
|
||||
(require mzlib/runtime-path)
|
||||
(provide (all-from-out mzlib/runtime-path)
|
||||
(for-syntax #%datum))
|
||||
(for-syntax #%datum)
|
||||
define-runtime-module-path)
|
||||
|
||||
(define-syntax (define-runtime-module-path stx)
|
||||
(syntax-case stx ()
|
||||
[(_ id mod-path)
|
||||
(begin
|
||||
(unless (memq (syntax-local-context) '(top-level module module-begin))
|
||||
(raise-syntax-error #f
|
||||
"allowed only in a module top-level or top-level context"
|
||||
stx))
|
||||
(unless (identifier? #'id)
|
||||
(raise-syntax-error #f
|
||||
"expected an identifier to bind"
|
||||
stx
|
||||
#'id))
|
||||
(unless (module-path? (syntax->datum #'mod-path))
|
||||
(raise-syntax-error #f
|
||||
"expected a literal module path"
|
||||
stx
|
||||
#'mod-path))
|
||||
#`(begin
|
||||
(require (only-in (for-label mod-path)))
|
||||
(define id (combine-module-path (#%variable-reference) 'mod-path))))]))
|
||||
|
||||
(define (combine-module-path vr mod-path)
|
||||
(module-path-index-resolve (module-path-index-join
|
||||
mod-path
|
||||
(variable-reference->resolved-module-path vr))))
|
||||
|
|
|
@ -521,6 +521,28 @@ Like @scheme[define-runtime-path], but @scheme[expr] should produce a
|
|||
list of paths.}
|
||||
|
||||
|
||||
@defform[(define-runtime-module-path id module-path)]{
|
||||
|
||||
Similar to @scheme[define-runtime-path], but @scheme[id] is bound to a
|
||||
@tech{resolved module path}. The @tech{resolved module path} for
|
||||
@scheme[id] corresponds to @scheme[module-path] (with the same syntax
|
||||
as a module path for @scheme[require]), which can be relative to the
|
||||
enclosing module.
|
||||
|
||||
Use @scheme[define-runtime-module-path] to bind a module path that is
|
||||
passed to a reflective function like @scheme[dynamic-require] while
|
||||
also creating a module dependency for building and distributing
|
||||
executables.
|
||||
|
||||
The @scheme[define-runtime-module-path] form creates a
|
||||
@scheme[for-label] dependency from an enclosing module to
|
||||
@scheme[module-path]. Since the dependency is merely
|
||||
@scheme[for-label], @scheme[module-path] is not @tech{instantiate}d or
|
||||
@tech{visit}ed when the enclosing module is @tech{instantiate}d or
|
||||
@tech{visit}ed (unless such a dependency is created by other
|
||||
@scheme[require]s).}
|
||||
|
||||
|
||||
@defform[(runtime-paths module-path)]{
|
||||
|
||||
This form is mainly for use by tools such as executable builders. It
|
||||
|
@ -529,7 +551,8 @@ expands to a quoted list containing the run-time paths declared by
|
|||
declaration @scheme[expr]s, except that paths are converted to byte
|
||||
strings. The enclosing module must require (directly or indirectly)
|
||||
the module specified by @scheme[module-path], which is an unquoted
|
||||
module path.}
|
||||
module path. The resulting list does @emph{not} include module paths
|
||||
bound through @scheme[define-runtime-module-path].}
|
||||
|
||||
@;------------------------------------------------------------------------
|
||||
@section[#:tag "file-lib"]{More File and Directory Utilities}
|
||||
|
|
Loading…
Reference in New Issue
Block a user