1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
|
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!--
Generated from mzscheme.tex by tex2page, v 20050501
(running on MzScheme 352, unix),
(c) Dorai Sitaram,
http://www.ccs.neu.edu/~dorai/tex2page/tex2page-doc.html
-->
<head>
<title>
PLT MzScheme: Language Manual
</title>
<link rel="stylesheet" type="text/css" href="mzscheme-Z-S.css" title=default>
<meta name=robots content="noindex,follow">
</head>
<body>
<div id=content>
<div align=right class=navigation><i>[Go to <span><a href="mzscheme.html">first</a>, <a href="mzscheme-Z-H-7.html">previous</a></span><span>, <a href="mzscheme-Z-H-9.html">next</a></span> page<span>; </span><span><a href="mzscheme.html#node_toc_start">contents</a></span><span><span>; </span><a href="mzscheme-Z-H-22.html#node_index_start">index</a></span>]</i></div>
<p></p>
<a name="node_chap_8"></a>
<h1 class=chapter>
<div class=chapterheading><a href="mzscheme.html#node_toc_node_chap_8">Chapter 8</a></div><br>
<a href="mzscheme.html#node_toc_node_chap_8">Namespaces</a></h1>
<p><a name="node_idx_1646"></a></p>
<p>
<a name="node_idx_1648"></a>
MzScheme supports multiple <strong>namespaces</strong><a name="node_idx_1650"></a> for top-level
variable bindings, syntax bindings, module imports, and module
declarations.</p>
<p>
A new namespace is created with the <code class=scheme><code class=scheme>make-namespace</code></code> procedure,
which returns a first-class namespace value. A namespace is used by
setting the <code class=scheme><code class=scheme>current-namespace</code></code> parameter value (see
section <a href="mzscheme-Z-H-7.html#node_sec_7.9.1.5">7.9.1.5</a>), by providing the namespace to
procedures such as <code class=scheme><code class=scheme>eval</code></code> and <code class=scheme><span class=variable>eval-syntax</span></code>. The
MzScheme versions of the R5RS procedures
<a name="node_idx_1652"></a><code class=scheme>scheme-report-environment</code> and <a name="node_idx_1654"></a><code class=scheme>null-environment</code>
produce namespaces.<a name="node_call_footnote_21"></a><a href="#node_footnote_21"><sup><small>21</small></sup></a></p>
<p>
The current namespace is used by many procedures, including
<code class=scheme><code class=scheme>eval</code></code>, <code class=scheme><code class=scheme>load</code></code>, <code class=scheme><code class=scheme>compile</code></code>, and
<code class=scheme><code class=scheme>expand</code></code>.<a name="node_call_footnote_22"></a><a href="#node_footnote_22"><sup><small>22</small></sup></a> After an expression is
<code class=scheme><code class=scheme>eval</code></code>ed, the global variable references in the expression are
permanently attached to a particular namespace, so the current
namespace at the time that the code is executed is <em>not</em> used as
the namespace for referencing global variables in the expression.</p>
<p>
Example:
</p>
<div align=left><pre class=scheme>(<span class=keyword>define</span> <span class=variable>x</span> <span class=keyword>'</span><span class=variable>orig</span>) <span class=comment>; define in the original namespace </span>
<span class=comment>;; The following <code class=scheme><span class=keyword>let</span></code> expression is compiled in the original </span>
<span class=comment>;; namespace, so direct references to <code class=scheme><span class=variable>x</span></code> see <code class=scheme><span class=selfeval>'orig</span></code>. </span>
(<span class=keyword>let</span> ([<span class=variable>n</span> (<code class=scheme>make-namespace</code>)]) <span class=comment>; make new namespace </span>
(<span class=keyword>parameterize</span> ([<code class=scheme>current-namespace</code> <span class=variable>n</span>])
(<code class=scheme>eval</code> <span class=keyword>'</span>(<span class=keyword>define</span> <span class=variable>x</span> <span class=keyword>'</span><span class=keyword>new</span>)) <span class=comment>; evals in the new namespace </span>
(<code class=scheme>display</code> <span class=variable>x</span>) <span class=comment>; displays 'orig </span>
(<code class=scheme>display</code> (<code class=scheme>eval</code> <span class=keyword>'</span><span class=variable>x</span>)))) <span class=comment>; displays 'new </span>
</pre></div><p></p>
<p>
A namespace actually encapsulates three top-level environments: one
for normal expressions, one for macro transformer expressions, and
one for macro templates; see section <a href="mzscheme-Z-H-12.html#node_chap_12">12</a> for more information
about the transformer environment, and see section <a href="mzscheme-Z-H-12.html#node_sec_12.3.4">12.3.4</a> for more
information about the template environment. Module declarations are
shared by the environments, but module instances, variable bindings,
syntax bindings, and module imports are distinct. More precisely, the
transformer environment never contains any syntax bindings, and its
variables, module instances, and module imports are distinct from the
variables, module instances, and module imports of the normal
top-level environment. The template environment contains module
imports, only.</p>
<p>
Each namespace has a <strong>module registry</strong><a name="node_idx_1656"></a> that maps module names
to module declarations (see Chapter <a href="mzscheme-Z-H-5.html#node_chap_5">5</a>). The
<code class=scheme>module->namespace</code> procedure returns a namespace with the
same module registry as the current namespace, but whose environment
and bindings correspond to the body of an instantiated module. (This
facility is primarily useful for debugging, and its use is limited by
the current code inspector; see also section <a href="mzscheme-Z-H-9.html#node_sec_9.4">9.4</a>.)</p>
<p>
</p>
<a name="node_sec_8.1"></a>
<h2><a href="mzscheme.html#node_toc_node_sec_8.1">8.1 Identifier Resolution in Namespaces</a></h2>
<p><a name="node_idx_1658"></a></p>
<p>
Identifier resolution in a namespace's top-level environment, for
compilation or expansion, proceeds in two steps. First, the
environment determines whether the identifier is mapped to a
top-level variable, to syntax, or to a module import (which can be
either syntax or a variable). Second, if the identifier is mapped to
a top-level variable, then the variable's location is found; if the
identifier is mapped to syntax, then the expansion-time binding is
found; and if the identifier is mapped to an import, then the source
module is consulted.</p>
<p>
Importing a variable from a module with <code class=scheme><span class=keyword>require</span></code> is <em>not</em>
the same as defining the variable; the import does not create a new
top-level variable in the environment, but instead maps an identifier
to the module's variable, in the same way that a syntax definition
maps an identifier to a transformer.</p>
<p>
Redefining a previously-defined variable is the same as mutating the
variable with <code class=scheme><span class=keyword>set!</span></code>. Rebinding a syntax-bound or import-bound
identifier (to syntax or an import) replaces the old binding with the
new one for future uses of the environment.</p>
<p>
If an identifier is bound to syntax or to an import, then defining the
identifier as a variable shadows the syntax or import in future uses
of the environment. Similarly, if an identifier is bound to a
top-level variable, then binding the identifier to syntax or an
import shadows the variable; the variable's value remains unchanged,
however, and may be accessible through previously evaluated
expressions.</p>
<p>
Example:
</p>
<div align=left><pre class=scheme>(<span class=keyword>define</span> <span class=variable>x</span> <span class=selfeval>5</span>)
(<span class=keyword>define</span> (<span class=variable>f</span>) <span class=variable>x</span>)
<span class=variable>x</span> <span class=comment>; => <code class=schemeresponse><span class=selfeval>5</span></code></span>
(<span class=variable>f</span>) <span class=comment>; => <code class=schemeresponse><span class=selfeval>5</span></code></span>
(<span class=keyword>define-syntax</span> <tt>x</tt> (<span class=keyword>syntax-rules</span> ()))
<tt>x</tt> <span class=comment>; => bad syntax</span>
(<span class=variable>f</span>) <span class=comment>; => <code class=schemeresponse><span class=selfeval>5</span></code></span>
(<span class=keyword>define</span> <span class=variable>x</span> <span class=selfeval>7</span>)
<span class=variable>x</span> <span class=comment>; => <code class=schemeresponse><span class=selfeval>7</span></code></span>
(<span class=variable>f</span>) <span class=comment>; => <code class=schemeresponse><span class=selfeval>7</span></code></span>
(<span class=keyword>module</span> <span class=variable>m</span> <code class=scheme>mzscheme</code> (<span class=keyword>define</span> <span class=variable>x</span> <span class=selfeval>8</span>) (<span class=keyword>provide</span> <span class=variable>x</span>))
(<span class=keyword>require</span> <span class=variable>m</span>)
<span class=variable>x</span> <span class=comment>; => <code class=schemeresponse><span class=selfeval>8</span></code></span>
(<span class=variable>f</span>) <span class=comment>; => <code class=schemeresponse><span class=selfeval>7</span></code></span>
</pre></div><p></p>
<p>
</p>
<a name="node_sec_8.2"></a>
<h2><a href="mzscheme.html#node_toc_node_sec_8.2">8.2 Initial Namespace</a></h2>
<p><a name="node_idx_1660"></a></p>
<p>
<a name="node_idx_1662"></a>
<a name="node_idx_1664"></a>
In the stand-alone MzScheme application, the initial namespace's
module registry contains declarations for <code class=scheme><code class=scheme>mzscheme</code></code> and the
primitive <code class=scheme><span class=selfeval>#%</span></code>-named modules (see section <a href="mzscheme-Z-H-5.html#node_sec_5.7">5.7</a>). The
normal top-level environment of the initial namespace contains
imports for all MzScheme syntax, and it contains variable bindings
(as opposed to imports) for every built-in procedure and constant.
The transformer top-level environment of the initial namespace
imports all MzScheme syntax, procedures, and constants.</p>
<p>
Applications embedding MzScheme may extend or modify the set of
initial bindings, but they will usually only add primitive modules
with <code class=scheme><span class=selfeval>#%</span></code>-prefixed names. (MrEd adds <code class=scheme>#%mred-kernel</code>
for its graphical toolbox.)</p>
<p>
</p>
<a name="node_sec_8.3"></a>
<h2><a href="mzscheme.html#node_toc_node_sec_8.3">8.3 Namespace Utilities</a></h2>
<p><a name="node_idx_1666"></a></p>
<p>
<a name="node_idx_1668"></a><a name="node_kw_definitionmake-namespace"></a><code class=scheme>(make-namespace</code><tt> </tt>[<code class=scheme><span class=variable>flag-symbol</span></code>]<code class=scheme>)</code> creates a new namespace with a
new module registry; the <code class=scheme><span class=variable>flag-symbol</span></code> is an option that
determines the initial bindings in the namespace. The allowed values
for <code class=scheme><span class=variable>flag-symbol</span></code> are:
</p>
<ul><p>
</p>
<li><p><code class=scheme><span class=selfeval>'initial</span></code><a name="node_idx_1670"></a> (the default) -- the new namespace
contains the module declarations of the initial namespace (see
section <a href="#node_sec_8.2">8.2</a>), and the new namespace's normal top-level
environment contains bindings and imports as in the initial
namespace. However, the namespace's transformer top-level
environment is empty.</p>
<p>
</p>
<li><p><code class=scheme><span class=selfeval>'empty</span></code><a name="node_idx_1672"></a> -- creates a namespace with no initial
bindings or module declarations.</p>
<p>
</p>
</ul><p></p>
<p>
<a name="node_idx_1674"></a><a name="node_kw_definitionnamespace_Q_"></a><code class=scheme>(namespace?</code><tt> </tt><code class=scheme><span class=variable>v</span></code><code class=scheme>)</code> returns <code class=scheme><span class=selfeval>#t</span></code> if <code class=scheme><span class=variable>v</span></code> is a namespace value,
<code class=scheme><span class=selfeval>#f</span></code> otherwise.</p>
<p>
<a name="node_idx_1676"></a><a name="node_kw_definitionnamespace-symbol->identifier"></a><code class=scheme>(namespace-symbol->identifier</code><tt> </tt><code class=scheme><span class=variable>symbol</span></code><code class=scheme>)</code> is similar to
<code class=scheme>datum->syntax-object</code> (see section <a href="mzscheme-Z-H-12.html#node_sec_12.2.2">12.2.2</a>) restricted to
symbols. The lexical context of the resulting identifier corresponds
to the top-level environment of the current namespace; the identifier
has no source location or properties.</p>
<p>
<a name="node_idx_1678"></a><a name="node_kw_definitionnamespace-variable-value"></a><code class=scheme>(namespace-variable-value</code><tt> </tt><code class=scheme><span class=variable>symbol</span></code><tt> </tt>[<code class=scheme><span class=variable>use-mapping? failure-thunk
namespace</span></code>]<code class=scheme>)</code> returns a value for <code class=scheme><span class=variable>symbol</span></code> in <code class=scheme><span class=variable>namespace</span></code>, where
<code class=scheme><span class=variable>namespace</span></code> defaults to the current namespace. The returned value
depends on <code class=scheme><span class=variable>use-mapping?</span></code>:
</p>
<ul><p>
</p>
<li><p>If <code class=scheme><span class=variable>use-mapping?</span></code> is true (the default), and if
<code class=scheme><span class=variable>symbol</span></code> maps to a top-level variable or an imported variable
(see section <a href="#node_sec_8.1">8.1</a>), then the result is the same as evaluating
<code class=scheme><span class=variable>symbol</span></code> as an expression. If <code class=scheme><span class=variable>symbol</span></code> maps to syntax or
imported syntax, the <a name="node_idx_1680"></a><code class=scheme>exn:fail:syntax</code> exception is raised (or
<code class=scheme><span class=variable>failure-thunk</span></code> is called; see below). If <code class=scheme><span class=variable>symbol</span></code> is
mapped to an undefined variable or an uninitialized module
variable, the <a name="node_idx_1682"></a><code class=scheme>exn:fail:contract:variable</code> exception is raised (or
<code class=scheme><span class=variable>failure-thunk</span></code> is called).</p>
<p>
</p>
<li><p>If <code class=scheme><span class=variable>use-mapping?</span></code> is false, the namespace's syntax and
import mappings are ignored. Instead, the value of the top-level
variable named <code class=scheme><span class=variable>symbol</span></code> in namespace is returned. If the
variable is undefined, the <a name="node_idx_1684"></a><code class=scheme>exn:fail:contract:variable</code> exception is raised (or
<code class=scheme><span class=variable>failure-thunk</span></code> is called).</p>
<p>
</p>
</ul><p>
If <code class=scheme><span class=variable>failure-thunk</span></code> is provided, <code class=scheme>namespace-variable-value</code>
calls <code class=scheme><span class=variable>failure-thunk</span></code> to produce the return value in place of
raising an <a name="node_idx_1686"></a><code class=scheme>exn:fail:contract:variable</code> or <a name="node_idx_1688"></a><code class=scheme>exn:fail:syntax</code>
exception.</p>
<p>
<a name="node_idx_1690"></a><a name="node_kw_definitionnamespace-set-variable-value!"></a><code class=scheme>(namespace-set-variable-value!</code><tt> </tt><code class=scheme><span class=variable>symbol v</span></code><tt> </tt>[<code class=scheme><span class=variable>map? namespace</span></code>]<code class=scheme>)</code> sets
the value of <code class=scheme><span class=variable>symbol</span></code> in the top-level environment of
<code class=scheme><span class=variable>namespace</span></code> (where <code class=scheme><span class=variable>namespace</span></code> defaults to the current
namespace) defining <code class=scheme><span class=variable>symbol</span></code> if it is not already defined. If
<code class=scheme><span class=variable>map?</span></code> is supplied as true, then the namespace's identifier
mapping is also adjusted (see section <a href="#node_sec_8.1">8.1</a>) so that
<code class=scheme><span class=variable>symbol</span></code> maps to the variable. The default value for
<code class=scheme><span class=variable>map?</span></code> is <code class=scheme><span class=selfeval>#f</span></code>.</p>
<p>
<a name="node_idx_1692"></a><a name="node_kw_definitionnamespace-undefine-variable!"></a><code class=scheme>(namespace-undefine-variable!</code><tt> </tt><code class=scheme><span class=variable>symbol namespace</span></code><code class=scheme>)</code> removes the
<code class=scheme><span class=variable>symbol</span></code> variable, if any, in the top-level environment of the
<code class=scheme><span class=variable>namespace</span></code>, where <code class=scheme><span class=variable>namespace</span></code> defaults to the current
namespace. The namespace's identifier mapping is unaffected.</p>
<p>
<a name="node_idx_1694"></a><a name="node_kw_definitionnamespace-mapped-symbols"></a><code class=scheme>(namespace-mapped-symbols</code><tt> </tt>[<code class=scheme><span class=variable>namespace</span></code>]<code class=scheme>)</code> returns a list of all
symbols that are mapped to variables, syntax, and imports in
<code class=scheme><span class=variable>namespace</span></code>, where <code class=scheme><span class=variable>namespace</span></code> defaults to the current
namespace.</p>
<p>
<a name="node_idx_1696"></a><a name="node_kw_definitionnamespace-require"></a><code class=scheme>(namespace-require</code><tt> </tt><code class=scheme><span class=variable>quoted-require-spec</span></code><code class=scheme>)</code> performs the import
corresponding to <code class=scheme><span class=variable>quoted-require-spec</span></code> in the top-level
environment of the current namespace (like a top-level
<code class=scheme><span class=keyword>require</span></code> expression). See also Chapter <a href="mzscheme-Z-H-5.html#node_chap_5">5</a>. Module
paths in <code class=scheme><span class=variable>quoted-require-spec</span></code> are not resolved with respect to
any other module, even if the current namespace corresponds to a
module body.</p>
<p>
<a name="node_idx_1698"></a><a name="node_kw_definitionnamespace-transformer-require"></a><code class=scheme>(namespace-transformer-require</code><tt> </tt><code class=scheme><span class=variable>quoted-require-spec</span></code><code class=scheme>)</code> performs the
import corresponding to <code class=scheme><span class=variable>quoted-require-spec</span></code> in the top-level
transformer environment (like a top-level <code class=scheme><span class=keyword>require-for-syntax</span></code>
expression). See also Chapter <a href="mzscheme-Z-H-5.html#node_chap_5">5</a>. Module paths in
<code class=scheme><span class=variable>quoted-require-spec</span></code> are not resolved with respect to any other
module, even if the current namespace corresponds to a module body.</p>
<p>
<a name="node_idx_1700"></a><a name="node_kw_definitionnamespace-require/copy"></a><code class=scheme>(namespace-require/copy</code><tt> </tt><code class=scheme><span class=variable>quoted-require-spec</span></code><code class=scheme>)</code> is like
<code class=scheme>namespace-require</code> for syntax exported from the module, but
exported variables are treated differently: the export's current
value is copied to a top-level variable in the current namespace.</p>
<p>
<a name="node_idx_1702"></a><a name="node_kw_definitionnamespace-require/expansion-time"></a><code class=scheme>(namespace-require/expansion-time</code><tt> </tt><code class=scheme><span class=variable>quoted-require-spec</span></code><code class=scheme>)</code> is like
<code class=scheme>namespace-require</code>, but only the transformer part of the
module is executed. If the required module has not been invoked
before, the module's variables remain undefined.</p>
<p>
<a name="node_idx_1704"></a><a name="node_kw_definitionnamespace-attach-module"></a><code class=scheme>(namespace-attach-module</code><tt> </tt><code class=scheme><span class=variable>src-namespace
module-path-v</span></code><tt> </tt>[<code class=scheme><span class=variable>dest-namespace</span></code>]<code class=scheme>)</code> attaches the instantiated
module named by <code class=scheme><span class=variable>module-path-v</span></code> in <code class=scheme><span class=variable>src-namespace</span></code> to
the registry of <code class=scheme><span class=variable>dest-namespace</span></code> (which is the current namespace
if <code class=scheme><span class=variable>dest-namespace</span></code> is not supplied). If <code class=scheme><span class=variable>module-path-v</span></code>
is not a symbol, the current module name resolver is called to
resolve the path, but no module is loaded; the resolved form of
<code class=scheme><span class=variable>module-path-v</span></code> is used as the module name in
<code class=scheme><span class=variable>dest-namespace</span></code>. In addition to <code class=scheme><span class=variable>module-path-v</span></code>, every module that it imports
(directly or indirectly) is also recorded in the current namespace's
registry. If <code class=scheme><span class=variable>module-path-v</span></code> does not refer to an instantiated
module in <code class=scheme><span class=variable>src-namespace</span></code>, or if the name of any module to be
attached already has a different declaration or instance in
<code class=scheme><span class=variable>dest-namespace</span></code>, then the <a name="node_idx_1706"></a><code class=scheme>exn:fail:contract</code> exception is raised. The
inspector of the module invocation in <code class=scheme><span class=variable>dest-namespace</span></code> is the
same as inspector of the invocation in <code class=scheme><span class=variable>src-namespace</span></code>.</p>
<p>
<a name="node_idx_1708"></a><a name="node_kw_definitionnamespace-unprotect-module"></a><code class=scheme>(namespace-unprotect-module</code><tt> </tt><code class=scheme><span class=variable>inspector module-path-v</span></code><code class=scheme>)</code>namespace
changes the inspector for the instance of the module referenced by
<code class=scheme><span class=variable>module-path-v</span></code> in <code class=scheme><span class=variable>namespace</span></code>'s registry so that it is
controlled by the current code inspector. If <code class=scheme><span class=variable>namespace</span></code> is not
supplied, it is the current namespace. The given <code class=scheme><span class=variable>inspector</span></code> must
currently control the invocation of the module in <code class=scheme><span class=variable>namespace</span></code>'s
registry, otherwise the <a name="node_idx_1710"></a><code class=scheme>exn:fail:contract</code> exception is raised. See also
section <a href="mzscheme-Z-H-9.html#node_sec_9.4">9.4</a>.</p>
<p>
<a name="node_idx_1712"></a><a name="node_kw_definitionnamespace-module-registry"></a><code class=scheme>(namespace-module-registry</code><tt> </tt><code class=scheme><span class=variable>namespace</span></code><code class=scheme>)</code> returns the registry of the
given namespace. This value is useful only for identification via
<code class=scheme><code class=scheme>eq?</code></code>.</p>
<p>
<a name="node_idx_1714"></a><a name="node_kw_definitionmodule->namespace"></a><code class=scheme>(module->namespace</code><tt> </tt><code class=scheme><span class=variable>module-path-v</span></code><code class=scheme>)</code> returns a namespace that
corresponds to the body of an instantiated module in the current
namespace's registry. The returned namespace has the same module
registry as the current namespace. Modifying a binding in the
namespace changes the binding seen in modules that require the
namespace's module. Module paths in a top-level <code class=scheme><span class=keyword>require</span></code>
expression are resolved with respect to the namespace's module. New
<code class=scheme><span class=keyword>provide</span></code> declarations are not allowed. If the current code
inspector does not control the invocation of the module in the
current namespace's registry, the <a name="node_idx_1716"></a><code class=scheme>exn:fail:contract</code> exception is raised; see
also section <a href="mzscheme-Z-H-9.html#node_sec_9.4">9.4</a>. Bindings in the namespace cannot be
modified if the <code class=scheme>compile-enforce-module-constants</code> parameter
was true when the module was declared, unless the module declaration
itself included assignments to the binding via <code class=scheme><span class=keyword>set!</span></code>.</p>
<p>
<a name="node_idx_1718"></a><a name="node_kw_definitionnamespace-syntax-introduce"></a><code class=scheme>(namespace-syntax-introduce</code><tt> </tt><code class=scheme><span class=variable>stx</span></code><code class=scheme>)</code> returns a syntax object like
<code class=scheme><span class=variable>stx</span></code>, except that the current namespace's bindings are included
in the syntax object's context (see section <a href="mzscheme-Z-H-12.html#node_sec_12.3">12.3</a>). The
additional context is overridden by any existing top-level context in
the syntax object, or by any existing or future module context. See
section <a href="mzscheme-Z-H-12.html#node_sec_12.2">12.2</a> for more information about syntax objects.</p>
<p>
<a name="node_idx_1720"></a><a name="node_kw_definitionmodule-provide-protected_Q_"></a><code class=scheme>(module-provide-protected?</code><tt> </tt><code class=scheme><span class=variable>module-path-index symbol</span></code><code class=scheme>)</code> returns
<code class=scheme><span class=selfeval>#f</span></code> if the module declaration for <code class=scheme><span class=variable>module-path-index</span></code>
defines <code class=scheme><span class=variable>symbol</span></code> and exports it unprotected, <code class=scheme><span class=selfeval>#t</span></code>
otherwise (which may mean that the symbol corresponds to an
unexported definition, a protected export, or an identifier that is
not defined at all within the module). The <code class=scheme><span class=variable>module-path-index</span></code>
argument can be a symbol; see section <a href="mzscheme-Z-H-12.html#node_sec_12.6.5">12.6.5</a> for more information
on module path indices. Typically, the arguments to
<code class=scheme><code class=scheme>module-provide-protected?</code></code> correspond to the first two
elements of a list produced by <code class=scheme><code class=scheme>identifier-binding</code></code> (see
section <a href="mzscheme-Z-H-12.html#node_sec_12.3">12.3</a>).</p>
<p>
</p>
<p>
</p>
<div class=footnoterule><hr></div><p></p>
<div class=footnote><p><a name="node_footnote_21"></a><a href="#node_call_footnote_21"><sup><small>21</small></sup></a> The resulting namespace contains syntax
imports for <code class=scheme><span class=keyword>#%app</span></code>, <code class=scheme><span class=keyword>#%datum</span></code>, and <code class=scheme><span class=keyword>#%top</span></code>,
because syntax expansion requires them (see section <a href="mzscheme-Z-H-12.html#node_sec_12.5">12.5</a>), but
those names are not legal <em>R5RS</em> identifiers.</p>
<p><a name="node_footnote_22"></a><a href="#node_call_footnote_22"><sup><small>22</small></sup></a> More precisely, the current namespace is
used by the evaluation and load handlers, rather than directly by
<code class=scheme><code class=scheme>eval</code></code> and <code class=scheme><code class=scheme>load</code></code>.</p>
</div>
<div align=right class=navigation><i>[Go to <span><a href="mzscheme.html">first</a>, <a href="mzscheme-Z-H-7.html">previous</a></span><span>, <a href="mzscheme-Z-H-9.html">next</a></span> page<span>; </span><span><a href="mzscheme.html#node_toc_start">contents</a></span><span><span>; </span><a href="mzscheme-Z-H-22.html#node_index_start">index</a></span>]</i></div>
<p></p>
</div>
</body>
</html>
|