
requiring itself into the entered namespace.
This makes it useful in some cases where this require leads to a
dependency cycle, eg (enter! racket/list). It's obviously not useful
for use as-is, since you will not have a bound `enter!' to get out of
the namespace (and possibly no `require' to get it) -- but it is useful
for meta-tools like xrepl. This is why the flag is verbose. `xrepl'
now uses this flag.
Also, the check for valid keywords for the form is now done at runtime
rather than in the macro. This doesn't matter in this case, since the
form is intended for interactive use anyway.
Also, separate the two parts of `enter-load/use-compiled' (it was
defined curried, but didn't use it).
(cherry picked from commit db7f2b4542
)
43 lines
2.0 KiB
Racket
43 lines
2.0 KiB
Racket
#lang scribble/doc
|
|
@(require "mz.rkt" (for-label racket/enter))
|
|
|
|
@title[#:tag "enter"]{Interactive Module Loading}
|
|
|
|
@note-init-lib[racket/enter]
|
|
|
|
@defform*[[(enter! module-path)
|
|
(enter! #f)
|
|
(enter! module-path flag ...+)]]{
|
|
|
|
Intended for use in a @tech{REPL}, such as when @exec{racket} is
|
|
started in interactive mode. When a @racket[module-path] is provided
|
|
(in the same sense as for @racket[require]), the corresponding module
|
|
is loaded or invoked, and the current @tech{namespace} is changed to
|
|
the body of the module via @racket[module->namespace]. When
|
|
@racket[#f] is provided, then the current @tech{namespace} is restored
|
|
to the original one.
|
|
|
|
If invoking @racket[module-path] requires loading any files, then
|
|
modification dates of the files are recorded. If the file is modified,
|
|
then a later @racket[enter!] re-loads the module from source; see also
|
|
@secref["module-redeclare"]. Similarly if a later @racket[enter!]
|
|
transitively @racket[require]s a modified module, then the required
|
|
module is re-loaded. Re-loading support works only for modules that
|
|
are first loaded (either directly or indirectly through transitive
|
|
@racket[require]s) via @racket[enter!].
|
|
|
|
Additional @racket[flag]s can customize aspects of @racket[enter!]:
|
|
@itemize[
|
|
@item{When @racket[enter!] loads or re-loads a module from a file, it
|
|
can print a message to @racket[(current-error-port)]. Use a
|
|
@racket[#:verbose] flag to print a message about such loads and
|
|
re-loads, @racket[#:verbose-reload] to print a message only for
|
|
re-loaded modules, and @racket[#:quiet] for no printouts. The default
|
|
reporting corresponds to @racket[#:verbose-reload].}
|
|
@item{After switching namespaces to the designated module,
|
|
@racket[enter!] automatically requires @racket[racket/enter] into the
|
|
namespace, so that @racket[enter!] can be used to switch namespaces
|
|
again. In some cases this might not be desirable (e.g., in a tool
|
|
that uses @racket[racket/enter])---use a
|
|
@racket[#:dont-re-require-enter] to diable this.}]
|