{"size": 1974, "ext": "scrbl", "max_stars_repo_path": "pkgs/racket-doc/scribblings/reference/load-lang.scrbl", "max_stars_repo_name": "lkh01/racket", "max_stars_repo_stars_event_min_datetime": "2018-07-29T04:13:52.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T16:11:17.000Z", "max_issues_repo_path": "pkgs/racket-doc/scribblings/reference/load-lang.scrbl", "max_issues_repo_name": "lkh01/racket", "max_issues_repo_issues_event_min_datetime": "2017-08-25T20:26:37.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T17:48:40.000Z", "max_forks_repo_path": "pkgs/racket-doc/scribblings/reference/load-lang.scrbl", "max_forks_repo_name": "lkh01/racket", "max_forks_repo_forks_event_min_datetime": "2016-04-25T11:47:57.000Z", "max_forks_repo_forks_event_max_datetime": "2017-05-09T14:52:48.000Z"}
{"max_stars_count": 10, "max_issues_count": 15, "max_forks_count": 3, "avg_line_length": 32.9, "max_line_length": 70, "alphanum_fraction": 0.7806484296}
#lang scribble/doc
@(require "mz.rkt")

@title[#:tag "load-lang"]{The @racketmodname[racket/load] Language}

@defmodulelang[racket/load]

The @racketmodname[racket/load] language supports evaluation where
each top-level form in the module body is separately passed to
@racket[eval] in the same way as for @racket[load].

The namespace for evaluation shares the @tech{module registry} with
the @racketmodname[racket/load] module instance, but it has a separate
top-level environment, and it is initialized with the bindings of
@racketmodname[racket]. A single namespace is created for each
instance of the @racketmodname[racket/load] module (i.e., multiple
modules using the @racketmodname[racket/load] language share a
namespace). The @racket[racket/load] library exports only
@racketidfont{#%module-begin} and @racketidfont{#%top-interaction}
forms that effectively swap in the evaluation namespace and call
@racket[eval].

For example, the body of a module using @racket[racket/load] can
include @racket[module] forms, so that running the following module
prints @racketresultfont{5}:

@racketmod[
racket/load

(module m racket/base
  (provide x)
  (define x 5))

(module n racket/base
  (require 'm)
  (display x))

(require 'n)
]

Definitions in a module using @racket[racket/load] are evaluated in
the current namespace, which means that @racket[load] and
@racket[eval] can see the definitions. For example, running the
following module prints @racketresultfont{6}:

@racketmod[
racket/load

(define x 6)
(display (eval 'x))
]

Since all forms within a @racketmodname[racket/load] module are
evaluated in the top level, bindings cannot be exported from the
module using @racket[provide]. Similarly, since evaluation of the
module-body forms is inherently dynamic, compilation of the module
provides essentially no benefit. For these reasons, use
@racketmodname[racket/load] for interactive exploration of top-level
forms only, and not for constructing larger programs.
