On this page:
lazy-require
begin-on-demand
Version: 5.3

16 Lazy Require

Ryan Culpepper <ryanc@racket-lang.org>

This library is unstable; compatibility will not be maintained. See Unstable: May Change Without Warning for more information.

 (require unstable/lazy-require)

syntax

(lazy-require [mod (imported-fun-id ...)] ...)

 
mod = module-path
  | ,module-path-expr
 
  module-path-expr : module-path?
Defines each imported-fun-id as a function that, when called, dynamically requires the export named 'imported-fun-id from the module specified by mod and calls it with the same arguments.

The module mod can be specified as a module-path (see require) or as an unquote-escaped expression that computes a module path. As with define-runtime-module-path-index, a module-path-expr is evaluated both in phase 0 and phase 1.

syntax

(begin-on-demand #:export (fun-id ...)
   body ...+)
Defines each fun-id as a function that, when called, dynamically loads and executes the body forms. The body forms must contain definitions for each fun-id, and the value of each fun-id must be a function.

A body form may be any module-level form except provide. In particular, require forms are allowed.

The body forms are placed within a submodule that extends the scope of the enclosing module (ie, module* with #f in the language position). Consequently, any references to sibling submodules must include a with ".." module path element.