► |  | The Racket Reference

1 | Language Model
2 | Notation for Documentation
3 | Syntactic Forms
4 | Datatypes
5 | Structures
6 | Classes and Objects
7 | Units
8 | Contracts
9 | Pattern Matching
10 | Control Flow
11 | Concurrency and Parallelism
12 | Macros
13 | Input and Output
14 | Reflection and Security
15 | Operating System
16 | Memory Management
17 | Unsafe Operations
18 | Running Racket
| Bibliography
| Index

▼ | 18 | Running Racket

18.1 | Running Racket or GRacket
18.2 | Libraries and Collections
18.3 | Interactive Help
18.4 | Interactive Module Loading
18.5 | Debugging
18.6 | Kernel Forms and Functions

► | 18.4 | Interactive Module Loading

18.4.1 | Entering Modules
18.4.2 | Loading and Reloading Modules

On this page:

18.4.1`` Entering Modules
enter!
18.4.2`` Loading and Reloading Modules
dynamic-rerequire

top ← prev up next →

#### 18.4`` Interactive Module Loading

The racket/rerequire and racket/enter libraries provide support for loading, reloading, and using modules.

##### 18.4.1`` Entering Modules

(require racket/enter) | package: base

The bindings documented in this section are provided by the racket/enter and racket/init libraries, which means that they are available when the Racket executable is started with no command-line arguments. They are not provided by racket/base or racket.

> syntax (enter! module-path)
> (enter! #f)
> (enter! module-path flag ...+)
> flag |  | = |  | #:quiet
> |  | | |  | #:verbose-reload
> |  | | |  | #:verbose
> |  | | |  | #:dont-re-require-enter

Intended for use in a REPL, such as when racket is started in interactive mode. When a module-path is provided (in the same sense as for require), the corresponding module is loaded or invoked via dynamic-rerequire, and the current namespace is changed to the body of the module via module->namespace. When #f is provided, then the current namespace is restored to the original one.

Additional flags can customize aspects of enter!:

- The #:verbose, #:verbose-reload, and #:quiet flags correspond to 'all, 'reload, and 'none verbosity for dynamic-rerequire. The default corresponds to #:verbose-reload.

- After switching namespaces to the designated module, enter! automatically requires racket/enter into the namespace, so that enter! can be used to switch namespaces again. In some cases, requiring racket/enter might not be desirable (e.g., in a tool that uses racket/enter); use the #:dont-re-require-enter flag to disable the require.

##### 18.4.2`` Loading and Reloading Modules

(require racket/rerequire) | package: base

The bindings documented in this section are provided by the racket/rerequire library, not racket/base or racket.

> > procedure
> > (dynamic-rerequire |  | module-path |  |  |  |
> > | [ | #:verbosity verbosity]) |  | → |  | void?
> module-path : module-path?
> verbosity : (or/c 'all 'reload 'none) = 'reload

Like (dynamic-require module-path 0), but with reloading support. The dynamic-rerequire function is intended for use in an interactive environment, especially via enter!.

If invoking module-path requires loading any files, then modification dates of the files are recorded. If the file is modified, then a later dynamic-rerequire re-loads the module from source; see also Module Redeclarations. Similarly if a later dynamic-rerequire transitively requires 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 requires) via dynamic-rerequire.

When enter! loads or re-loads a module from a file, it can print a message to (current-error-port), depending on verbosity: 'verbose prints a message for all loads and re-loads, 'reload prints a message only for re-loaded modules, and 'none disables printouts.

top ← prev up next →