emacs.d/clones/lisp/docs.racket-lang.org/reference/module.html

196 lines
70 KiB
HTML
Raw Normal View History

2022-08-24 19:36:32 +02:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=0.8"/><title>3.1&nbsp;Modules: module, module*, ...</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="icons.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">The Racket Reference</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="syntax.html" class="tocviewselflink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operatio
module, if the <span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._current-module-declare-name%29%29" class="RktValLink" data-pltdoc="x">current-module-declare-name</a></span> parameter is set,
the parameter value is used for the module name and <span class="RktVar">id</span> is
ignored, otherwise <span class="RktPn">(</span><span class="RktSym"><a href="quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">quote</a></span><span class="stt"> </span><span class="RktVar">id</span><span class="RktPn">)</span> is the name of the
declared module. For a <a href="eval-model.html#%28tech._submodule%29" class="techoutside" data-pltdoc="x"><span class="techinside">submodule</span></a>, <span class="RktVar">id</span> is the name of
the submodule to be used as an element within a <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._submod%29%29" class="RktStxLink" data-pltdoc="x">submod</a></span> module
path. A <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> form is not allowed in an <a href="syntax-model.html#%28tech._expression._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">expression context</span></a>
or <a href="syntax-model.html#%28tech._internal._definition._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">internal-definition context</span></a>.</div></p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="magnify.png" alt="+" width="24" height="24"/></span>For a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span>-like form that works in
definitions context other than the top level or a module body, see
<span class="RktSym"><a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=compatibility&amp;rel=compatibility-package.html%23%2528form._%2528%2528lib._compatibility%252Fpackage..rkt%2529._define-package%2529%2529&amp;version=8.6" class="RktStxLink Sq" data-pltdoc="x">define-package</a></span>.</p></blockquote></blockquote></blockquote><p>The <span class="RktVar">module-path</span> form must be as for <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span>, and it
supplies the initial bindings for the body <span class="RktVar">form</span>s. That is, it
is treated like a <span class="RktPn">(</span><span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><span class="RktVar">module-path</span><span class="RktPn">)</span> prefix before the
<span class="RktVar">form</span>s, except that the bindings introduced by
<span class="RktVar">module-path</span> can be shadowed by definitions and
<span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span>s in the module body <span class="RktVar">form</span>s.</p><p>If a single <span class="RktVar">form</span> is provided, then it is partially expanded
in a <a href="syntax-model.html#%28tech._module._begin._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">module-begin context</span></a>. If the expansion leads to
<span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29" class="RktStxLink" data-pltdoc="x">#%plain-module-begin</a></span>, then the body of the
<span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29" class="RktStxLink" data-pltdoc="x">#%plain-module-begin</a></span> is the body of the module. If partial
expansion leads to any other primitive form, then the form is wrapped
with <span class="RktSym">#%module-begin</span> using the lexical context of the
module body; this identifier must be bound by the initial
<span class="RktVar">module-path</span> import, and its expansion must produce a
<span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29" class="RktStxLink" data-pltdoc="x">#%plain-module-begin</a></span> to supply the module body. Finally, if
multiple <span class="RktVar">form</span>s are provided, they are wrapped with
<span class="RktSym">#%module-begin</span>, as in the case where a single
<span class="RktVar">form</span> does not expand to <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29" class="RktStxLink" data-pltdoc="x">#%plain-module-begin</a></span>.</p><p>After such wrapping, if any, and before any expansion, an
<a name="(idx._(gentag._98._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">enclosing-module-name</span> property is attached to the
<span class="RktSym">#%module-begin</span> syntax object (see
<a href="stxprops.html" data-pltdoc="x">Syntax Object Properties</a>); the property&rsquo;s value is a symbol
corresponding to <span class="RktVar">id</span>.</p><p>Each <span class="RktVar">form</span> is partially expanded (see
<a href="syntax-model.html#%28part._partial-expansion%29" data-pltdoc="x">Partial Expansion</a>) in a <a href="syntax-model.html#%28tech._module._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">module context</span></a>. Further
action depends on the shape of the form:</p><ul><li><p>If it is a <span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29" class="RktStxLink" data-pltdoc="x">begin</a></span> form, the sub-forms are flattened
out into the module&rsquo;s body and immediately processed in place of the
<span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29" class="RktStxLink" data-pltdoc="x">begin</a></span>.</p></li><li><p>If it is a <span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-syntaxes%29%29" class="RktStxLink" data-pltdoc="x">define-syntaxes</a></span> form, then the right-hand side is
evaluated (in <a href="eval-model.html#%28tech._phase%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase</span></a> 1), and the binding is immediately
installed for further partial expansion within the
module. Evaluation of the right-hand side is <span class="RktSym"><a href="parameters.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._parameterize%29%29" class="RktStxLink" data-pltdoc="x">parameterize</a></span>d
to set <span class="RktSym"><a href="Namespaces.html#%28def._%28%28quote._~23~25kernel%29._current-namespace%29%29" class="RktValLink" data-pltdoc="x">current-namespace</a></span> as in <span class="RktSym"><a href="let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let-syntax%29%29" class="RktStxLink" data-pltdoc="x">let-syntax</a></span>.</p></li><li><p>If it is a <span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29" class="RktStxLink" data-pltdoc="x">begin-for-syntax</a></span> form, then the body is
expanded (in <a href="eval-model.html#%28tech._phase%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase</span></a> 1) and evaluated. Expansion within a
<span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29" class="RktStxLink" data-pltdoc="x">begin-for-syntax</a></span> form proceeds with the same
partial-expansion process as for a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> body, but in a
higher <a href="eval-model.html#%28tech._phase%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase</span></a>, and saving all <span class="RktSym"><a href="require.html#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29" class="RktStxLink" data-pltdoc="x">#%provide</a></span> forms for all
phases until the end of the <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span>&rsquo;s expansion. Evaluation
of the body is <span class="RktSym"><a href="parameters.html#%28form._%28%28lib._racket%2Fprivate%2Fmore-scheme..rkt%29._parameterize%29%29" class="RktStxLink" data-pltdoc="x">parameterize</a></span>d to set
<span class="RktSym"><a href="Namespaces.html#%28def._%28%28quote._~23~25kernel%29._current-namespace%29%29" class="RktValLink" data-pltdoc="x">current-namespace</a></span> as in <span class="RktSym"><a href="let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let-syntax%29%29" class="RktStxLink" data-pltdoc="x">let-syntax</a></span>.</p></li><li><p>If the form is a <span class="RktSym"><a href="require.html#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29" class="RktStxLink" data-pltdoc="x">#%require</a></span> form, bindings are introduced
immediately, and the imported modules are <a href="eval-model.html#%28tech._instantiate%29" class="techoutside" data-pltdoc="x"><span class="techinside">instantiate</span></a>d or
<a href="syntax-model.html#%28tech._visit%29" class="techoutside" data-pltdoc="x"><span class="techinside">visit</span></a>ed as appropriate.</p></li><li><p>If the form is a <span class="RktSym"><a href="require.html#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29" class="RktStxLink" data-pltdoc="x">#%provide</a></span> form, then it is recorded for
processing after the rest of the body.</p></li><li><p>If the form is a <span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29" class="RktStxLink" data-pltdoc="x">define-values</a></span> form, then the binding
is installed immediately, but the right-hand expression is not
expanded further.</p></li><li><p>If the form is a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> form, then it is immediately
expanded and declared for the extent of the current top-level
enclosing module&rsquo;s expansion.</p></li><li><p>If the form is a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> form, then it is not
expanded further.</p></li><li><p>Similarly, if the form is an expression, it is
not expanded further.</p></li></ul><p>After all <span class="RktVar">form</span>s have been partially expanded this way, then
the remaining expression forms (including those on the right-hand side
of a definition) are expanded in an expression context. After all
expression forms, <span class="RktSym"><a href="require.html#%28form._%28%28quote._~23~25kernel%29._~23~25provide%29%29" class="RktStxLink" data-pltdoc="x">#%provide</a></span> forms are processed in the order
in which they appear (independent of <a href="eval-model.html#%28tech._phase%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase</span></a>) in the expanded
module. Finally, all <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> forms are expanded in order, so
that each becomes available for use by subsequent <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span>
forms; the enclosing module itself is also available for use by
<span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> <a href="eval-model.html#%28tech._submodule%29" class="techoutside" data-pltdoc="x"><span class="techinside">submodules</span></a>.</p><p>The scope of all imported identifiers covers the entire module body,
except for nested <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> and <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> forms (assuming
a non-<span class="RktVal">#f</span> <span class="RktVar">module-path</span> in the latter case).
The scope of any identifier defined within the module body similarly
covers the entire module body except for such nested <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span>
and <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> forms.
The ordering of syntax definitions does not affect the scope of the
syntax names; a transformer for <span class="RktSym">A</span> can produce expressions
containing <span class="RktSym">B</span>, while the transformer for <span class="RktSym">B</span> produces
expressions containing <span class="RktSym">A</span>, regardless of the order of
declarations for <span class="RktSym">A</span> and <span class="RktSym">B</span>. However, a syntactic form
that produces syntax definitions must be defined before it is used.</p><p>No identifier can be imported or defined more than once at any
<a href="syntax-model.html#%28tech._phase._level%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase level</span></a> within a single module, except that a definition
via <span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29" class="RktStxLink" data-pltdoc="x">define-values</a></span> or <span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-syntaxes%29%29" class="RktStxLink" data-pltdoc="x">define-syntaxes</a></span> can shadow a
preceding import via <span class="RktSym"><a href="require.html#%28form._%28%28quote._~23~25kernel%29._~23~25require%29%29" class="RktStxLink" data-pltdoc="x">#%require</a></span>.
Every exported identifier must be imported or
defined. No expression can refer to a <a href="eval-model.html#%28tech._top._level._variable%29" class="techoutside" data-pltdoc="x"><span class="techinside">top-level variable</span></a>.
A <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> form in which the enclosing module&rsquo;s bindings are visible
(i.e., a nested <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> with <span class="RktVal">#f</span> instead of a <span class="RktVar">module-path</span>)
can define or import bindings that <a href="syntax-model.html#%28tech._shadow%29" class="techoutside" data-pltdoc="x"><span class="techinside">shadow</span></a> the enclosing module&rsquo;s bindings.</p><p>The evaluation of a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> form does not evaluate the
expressions in the body of the module (except sometimes for redeclarations;
see <a href="eval-model.html#%28part._module-redeclare%29" data-pltdoc="x">Module Redeclarations</a>). Evaluation merely declares a
module, whose full name depends both on <span class="RktVar">id</span> or
<span class="RktPn">(</span><span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._current-module-declare-name%29%29" class="RktValLink" data-pltdoc="x">current-module-declare-name</a></span><span class="RktPn">)</span>.</p><p>A module body is executed only when the module is explicitly
<a href="eval-model.html#%28tech._instantiate%29" data-pltdoc="x">instantiate</a>d via <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span> or
<span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29" class="RktValLink" data-pltdoc="x">dynamic-require</a></span>. On invocation, imported modules are
instantiated in the order in which they are <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span>d
into the module (although earlier instantiations or transitive
<span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span>s can trigger the instantiation of a module before
its order within a given module). Then, expressions and definitions
are evaluated in order as they appear within the module. Each
evaluation of an expression or definition is wrapped with a
continuation prompt (see <span class="RktSym"><a href="cont.html#%28def._%28%28quote._~23~25kernel%29._call-with-continuation-prompt%29%29" class="RktValLink" data-pltdoc="x">call-with-continuation-prompt</a></span>) for
the default <a href="eval-model.html#%28tech._prompt._tag%29" class="techoutside" data-pltdoc="x"><span class="techinside">prompt tag</span></a> and using a prompt handler that re-aborts
and propagates its argument to the next enclosing prompt. Each evaluation
of a definition is followed, outside of the prompt, by a check that
each of the definition&rsquo;s variables has a value; if the portion of the
prompt-delimited continuation that installs values is skipped, then
the <span class="RktSym"><a href="exns.html#%28def._%28%28quote._~23~25kernel%29._exn~3afail~3acontract~3avariable~3f%29%29" class="RktValLink" data-pltdoc="x">exn:fail:contract:variable?</a></span> exception is raised.</p><p>Portions of a module body at higher phase levels are delimited
similarly to run-time portions. For example, portions of a module
within <span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29" class="RktStxLink" data-pltdoc="x">begin-for-syntax</a></span> are delimited by a continuation
prompt both as the module is expanded and when it is visited. The
evaluation of a <span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-syntaxes%29%29" class="RktStxLink" data-pltdoc="x">define-syntaxes</a></span> form is delimited, but unlike
<span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29" class="RktStxLink" data-pltdoc="x">define-values</a></span>, there is no check that the syntax definition
completed.</p><p>Accessing a <a href="eval-model.html#%28tech._module._level._variable%29" class="techoutside" data-pltdoc="x"><span class="techinside">module-level variable</span></a> before it is defined signals
a run-time error, just like accessing an undefined global variable.
If a module (in its fully expanded form) does not contain a
<span class="RktSym"><a href="set_.html#%28form._%28%28quote._~23~25kernel%29._set%21%29%29" class="RktStxLink" data-pltdoc="x">set!</a></span> for an identifier that defined within the module, then
the identifier is a <span style="font-style: italic">constant</span> after it is defined; its value
cannot be changed afterward, not even through reflective
mechanisms. The <span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._compile-enforce-module-constants%29%29" class="RktValLink" data-pltdoc="x">compile-enforce-module-constants</a></span> parameter,
however, can be used to disable enforcement of constants.</p><p>When a <a href="syntax-model.html#%28tech._syntax._object%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax object</span></a> representing a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> form has a
<a name="(idx._(gentag._99._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">module-language</span> <a href="stxprops.html#%28tech._syntax._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax property</span></a> attached, and
when the property value is a vector of three elements where the first
is a module path (in the sense of <span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._module-path~3f%29%29" class="RktValLink" data-pltdoc="x">module-path?</a></span>) and the
second is a symbol, then the property value is preserved in the
corresponding compiled and/or declared module. The third component of
the vector should be printable and <span class="RktSym"><a href="Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29" class="RktValLink" data-pltdoc="x">read</a></span>able, so that it can
be preserved in marshaled bytecode. The <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/base</span></a>
and <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket</span></a> languages attach
<span class="RktVal">'</span><span class="RktVal">#</span><span class="RktVal">(</span><span class="RktVal">racket/language-info</span><span class="stt"> </span><span class="RktVal">get-info</span><span class="stt"> </span><span class="RktVal">#f</span><span class="RktVal">)</span> to a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span>
form. See also <span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._module-compiled-language-info%29%29" class="RktValLink" data-pltdoc="x">module-compiled-language-info</a></span>,
<span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._module-~3elanguage-info%29%29" class="RktValLink" data-pltdoc="x">module-&gt;language-info</a></span>, and
<a href="running-sa.html#%28mod-path._racket%2Flanguage-info%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/language-info</span></a>.</p><p>See also <a href="eval-model.html#%28part._module-eval-model%29" data-pltdoc="x">Modules and Module-Level Variables</a>, <a href="syntax-model.html#%28part._mod-parse%29" data-pltdoc="x">Module Expansion, Phases, and Visits</a>, and
<a href="Expanding_Top-Level_Forms.html#%28part._modinfo%29" data-pltdoc="x">Information on Expanded Modules</a>.</p><p><div class="SIntrapara">Example:</div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span><span class="hspace">&nbsp;</span><span class="RktSym">duck</span><span class="hspace">&nbsp;</span><span class="RktSym">racket/base</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29" class="RktStxLink" data-pltdoc="x">provide</a></span><span class="hspace">&nbsp;</span><span class="RktSym">num-eggs</span><span class="hspace">&nbsp;</span><span class="RktSym">quack</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">num-eggs</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">quack</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="when_unless.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._unless%29%29" class="RktStxLink" data-pltdoc="x">unless</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._zero~3f%29%29" class="RktValLink" data-pltdoc="x">zero?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._printf%29%29" class="RktValLink" data-pltdoc="x">printf</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"quack\n"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">quack</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._sub1%29%29" class="RktValLink" data-pltdoc="x">sub1</a></span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div></p><p class="SHistory">Changed in version 6.3 of package <span class="stt">base</span>: Changed <span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-syntaxes%29%29" class="RktStxLink" data-pltdoc="x">define-syntaxes</a></span>
and <span class="RktSym"><a href="define.html#%28form._%28%28quote._~23~25kernel%29._define-values%29%29" class="RktStxLink" data-pltdoc="x">define-values</a></span> to
shadow any preceding import, and
dropped the use of <span class="RktVal">'</span><span class="RktVal">submodule</span>
<a href="stxprops.html#%28tech._syntax._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax property</span></a> values on nested
<span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> or <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span>
forms.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((quote._~23~25kernel)._module*))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">module*</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">id</span><span class="hspace">&nbsp;</span><span class="RktVar">module-path</span><span class="hspace">&nbsp;</span><span class="RktVar">form</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">module*</a></span><span class="hspace">&nbsp;</span><span class="RktVar">id</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="hspace">&nbsp;</span><span class="RktVar">form</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara"><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="finger.png" alt="+" width="24" height="24"/></span><a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=guide&amp;rel=Module_Syntax.html%23%2528part._submodules%2529&amp;version=8.6" class="Sq" data-pltdoc="x">Submodules</a> in <a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=guide&amp;rel=index.html&amp;version=8.6" class="Sq" data-pltdoc="x">The Racket Guide</a> introduces <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span>.</p></blockquote></blockquote></blockquote></div></p><p>Like <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span>, but only for declaring a <a href="eval-model.html#%28tech._submodule%29" class="techoutside" data-pltdoc="x"><span class="techinside">submodule</span></a> within
a module, and for submodules that may <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span> the enclosing module.</p><p>Instead of a <span class="RktVar">module-path</span> after <span class="RktVar">id</span>, <span class="RktVal">#f</span>
indicates that all bindings from the enclosing module are visible in
the submodule. In that case, <span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29" class="RktStxLink" data-pltdoc="x">begin-for-syntax</a></span> forms that wrap
the <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> form shift the <a href="syntax-model.html#%28tech._phase._level%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase level</span></a> of the
enclosing module&rsquo;s bindings relative to the submodule. The macro
expander handles such nesting by shifting the <a href="syntax-model.html#%28tech._phase._level%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase level</span></a> of
the <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> form so that its body starts at <a href="syntax-model.html#%28tech._phase._level%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase
level</span></a> 0, expanding, and then reverting the <a href="syntax-model.html#%28tech._phase._level%29" class="techoutside" data-pltdoc="x"><span class="techinside">phase level</span></a> shift;
beware that this process can leave <a href="syntax-model.html#%28tech._syntax._object%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax objects</span></a> as
<span class="RktVal">'</span><span class="RktVal">origin</span> <a href="stxprops.html#%28tech._syntax._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax property</span></a> values out-of-sync with the
expanded module.</p><p>When a <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> form has a <span class="RktVar">module-path</span>, the submodule
expansion starts by removing the <a href="syntax-model.html#%28tech._scope%29" class="techoutside" data-pltdoc="x"><span class="techinside">scopes</span></a> of the enclosing
module, the same as the <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> form. No shifting compensates
for any <span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin-for-syntax%29%29" class="RktStxLink" data-pltdoc="x">begin-for-syntax</a></span> forms that may wrap the submodule.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._module+))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">module+</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">id</span><span class="hspace">&nbsp;</span><span class="RktVar">form</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara"><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="finger.png" alt="+" width="24" height="24"/></span><a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=guide&amp;rel=Module_Syntax.html%23%2528part._main-and-test%2529&amp;version=8.6" class="Sq" data-pltdoc="x">Main and Test Submodules</a> in <a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=guide&amp;rel=index.html&amp;version=8.6" class="Sq" data-pltdoc="x">The Racket Guide</a> introduces <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span>.</p></blockquote></blockquote></blockquote></div></p><p>Declares and/or adds to a <a href="eval-model.html#%28tech._submodule%29" class="techoutside" data-pltdoc="x"><span class="techinside">submodule</span></a> named <span class="RktVar">id</span>.</p><p>Each addition for <span class="RktVar">id</span> is combined in order to form the entire
submodule using <span class="RktPn">(</span><span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span><span class="stt"> </span><span class="RktVar">id</span><span class="stt"> </span><span class="RktVal">#f</span><span class="stt"> </span><span class="RktSym">....</span><span class="RktPn">)</span> at the end of the
enclosing module. If there is only one <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span> for a given
<span class="RktVar">id</span>, then <span class="RktPn">(</span><span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span><span class="stt"> </span><span class="RktVar">id</span><span class="stt"> </span><span class="RktVar">form</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> is equivalent to
<span class="RktPn">(</span><span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span><span class="stt"> </span><span class="RktVar">id</span><span class="stt"> </span><span class="RktVal">#f</span><span class="stt"> </span><span class="RktVar">form</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span>, but still moved to the end of the
enclosing module.</p><p>When a module contains multiple submodules declared with
<span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span>, then the relative order of the initial
<span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span> declarations for each submodule determines the
relative order of the <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> declarations at the end of the
enclosing module.</p><p>A submodule must not be defined using <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span> <span class="emph">and</span>
<span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> or <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span>. That is, if a submodule is made
of <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span> pieces, then it must be made <span class="emph">only</span> of
<span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span> pieces. </p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._~23~25module-begin))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25module-begin%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">#%module-begin</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">form</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Legal only in a <a href="syntax-model.html#%28tech._module._begin._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">module begin context</span></a>, and handled by the
<span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> and <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> forms.</div></p><p>The <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25module-begin%29%29" class="RktStxLink" data-pltdoc="x">#%module-begin</a></span> form of <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/base</span></a> wraps
every top-level expression to print non-<a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=guide&amp;rel=void_undefined.html&amp;version=8.6" class="RktModLink Sq" data-pltdoc="x"><span class="nobreak"><span class="RktRes">#&lt;void&gt;</span></span></a> results using
<span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._current-print%29%29" class="RktValLink" data-pltdoc="x">current-print</a></span>.</p><p>The <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25module-begin%29%29" class="RktStxLink" data-pltdoc="x">#%module-begin</a></span> form of <a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/base</span></a> also
declares a <span class="RktSym">configure-runtime</span> submodule (before any other
<span class="RktVar">form</span>), unless some <span class="RktVar">form</span> is either an immediate
<span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> or <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> form with the name
<span class="RktSym">configure-runtime</span>. If a <span class="RktSym">configure-runtime</span> submodule
is added, the submodule calls the <span class="RktSym">configure</span> function of
<a href="running-sa.html#%28mod-path._racket%2Fruntime-config%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/runtime-config</span></a>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._~23~25printing-module-begin))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25printing-module-begin%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">#%printing-module-begin</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">form</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Legal only in a <a href="syntax-model.html#%28tech._module._begin._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">module begin context</span></a>.</div></p><p>Like <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25module-begin%29%29" class="RktStxLink" data-pltdoc="x">#%module-begin</a></span>, but without adding a
<span class="RktSym">configure-runtime</span> submodule.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._~23~25plain-module-begin))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~23~25plain-module-begin%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">#%plain-module-begin</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">form</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Legal only in a <a href="syntax-model.html#%28tech._module._begin._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">module begin context</span></a>, and handled by the
<span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> and <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%2A%29%29" class="RktStxLink" data-pltdoc="x">module*</a></span> forms.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((quote._~23~25kernel)._~23~25declare))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._~23~25declare%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">#%declare</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">declaration-keyword</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt">&nbsp;</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">declaration-keyword</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">#:cross-phase-persistent</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">#:empty-namespace</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">#:unsafe</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">#:realm</span><span class="hspace">&nbsp;</span><span class="RktVar">identifier</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Declarations that affect run-time or reflective properties of the
module:</div></p><ul><li><p><a name="(idx._(gentag._100._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktPn">#:cross-phase-persistent</span> &#8212;<wbr></wbr> declares the
module as <a href="eval-model.html#%28tech._cross._phase._persistent%29" class="techoutside" data-pltdoc="x"><span class="techinside">cross-phase persistent</span></a>, and reports a syntax
error if the module does not meet the import or syntactic
constraints of a <a href="eval-model.html#%28tech._cross._phase._persistent%29" class="techoutside" data-pltdoc="x"><span class="techinside">cross-phase persistent</span></a> module.</p></li><li><p><a name="(idx._(gentag._101._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktPn">#:empty-namespace</span> &#8212;<wbr></wbr> declares that
<span class="RktSym"><a href="Namespaces.html#%28def._%28%28quote._~23~25kernel%29._module-~3enamespace%29%29" class="RktValLink" data-pltdoc="x">module-&gt;namespace</a></span> for this module should produce a
namespace with no bindings; limiting namespace support in this
way can reduce the <a href="syntax-model.html#%28tech._lexical._information%29" class="techoutside" data-pltdoc="x"><span class="techinside">lexical information</span></a> that
otherwise must be preserved for the module.</p></li><li><p><a name="(idx._(gentag._102._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktPn">#:unsafe</span> &#8212;<wbr></wbr> declares that the module can be
compiled without checks that could trigger
<span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29" class="RktValLink" data-pltdoc="x">exn:fail:contract</a></span>, and the resulting behavior is
unspecified for an evaluation where <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29" class="RktValLink" data-pltdoc="x">exn:fail:contract</a></span>
should have been raised; see also <a href="unsafe.html" data-pltdoc="x">Unsafe Operations</a>. For
example, a use of <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> can be compiled as a use of
<span class="RktSym"><a href="unsafe.html#%28def._%28%28lib._racket%2Funsafe%2Fops..rkt%29._unsafe-car%29%29" class="RktValLink" data-pltdoc="x">unsafe-car</a></span>, and the behavior is unspecified is
<span class="RktSym"><a href="unsafe.html#%28def._%28%28lib._racket%2Funsafe%2Fops..rkt%29._unsafe-car%29%29" class="RktValLink" data-pltdoc="x">unsafe-car</a></span> is applied to a non-pair. The
<span class="RktPn">#:unsafe</span> declaration keyword is allowed only when the
current <a href="modprotect.html#%28tech._code._inspector%29" class="techoutside" data-pltdoc="x"><span class="techinside">code inspector</span></a> is the initial one. Macros can
generate conditionally unsafe code, depending on the expansion
context, by expanding to a use of
<span class="RktPn">(</span><span class="RktSym"><a href="Namespaces.html#%28def._%28%28quote._~23~25kernel%29._variable-reference-from-unsafe~3f%29%29" class="RktValLink" data-pltdoc="x">variable-reference-from-unsafe?</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Locations____variable-reference.html#%28form._%28%28quote._~23~25kernel%29._~23~25variable-reference%29%29" class="RktStxLink" data-pltdoc="x">#%variable-reference</a></span><span class="RktPn">)</span><span class="RktPn">)</span>.</p></li><li><p><a name="(idx._(gentag._103._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktPn">#:realm</span><span class="stt"> </span><span class="RktVar">identifier</span> &#8212;<wbr></wbr> declares that
the module and any procedures within the module are given a
<a href="exns.html#%28tech._realm%29" class="techoutside" data-pltdoc="x"><span class="techinside">realm</span></a> that is the symbol form of <span class="RktVar">identifier</span>, effectively
overriding the value of <span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._current-compile-realm%29%29" class="RktValLink" data-pltdoc="x">current-compile-realm</a></span>.</p></li></ul><p>A <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._~23~25declare%29%29" class="RktStxLink" data-pltdoc="x">#%declare</a></span> form must appear in a <a href="syntax-model.html#%28tech._module._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">module
context</span></a> or a <a href="syntax-model.html#%28tech._module._begin._context%29" class="techoutside" data-pltdoc="x"><span class="techinside">module-begin context</span></a>. Each
<span class="RktVar">declaration-keyword</span> can be declared at most once within a
<span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> body.</p><p class="SHistory">Changed in version 6.3 of package <span class="stt">base</span>: Added <span class="RktPn">#:empty-namespace</span>.<br/>Changed in version 7.9.0.5: Added <span class="RktPn">#:unsafe</span>.<br/>Changed in version 8.4.0.2: Added <span class="RktPn">#:realm</span>.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" id="searchbox" type="text" tabindex="1" placeholder="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;8.6&quot;, &quot;../&quot;);"/></form>&nbsp;&nbsp;<a href="https://docs.racket-lang.org/index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;8.6&quot;);">top</a><span class="tocsettoggle">&nbsp;&nbsp;<a href="javascript:void(0);" title="show/hide table of contents" onclick="TocsetToggle();">contents</a></span></span><span class="navright">&nbsp;&nbsp;<a href="syntax.html" title="backward to &quot;3 Syntactic Forms&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="syntax.html" title="up to &quot;3 Syntactic Forms&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="require.html" title="forward to &quot;3.2 Importing and Exporting: require and provide&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>