51 lines
41 KiB
HTML
51 lines
41 KiB
HTML
|
<!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>12.9 Expanding Top-Level Forms</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="../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,"tocview_0");">►</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 </td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2 </td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3 </td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4 </td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5 </td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6 </td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7 </td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8 </td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9 </td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10 </td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11 </td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12 </td><td><a href="Macros.html" class="tocviewselflink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13 </td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14 </td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15 </td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16 </td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17 </td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18 </td><td><a href="running.html
|
||
|
returns a syntax object for the expanded form that contains only core
|
||
|
forms, matching the grammar specified by <a href="syntax-model.html#%28part._fully-expanded%29" data-pltdoc="x">Fully Expanded Programs</a>.</div></p><p>Before <span class="RktVar">top-level-form</span> is expanded, its lexical context is
|
||
|
enriched with <span class="RktSym"><a href="Namespaces.html#%28def._%28%28quote._~23~25kernel%29._namespace-syntax-introduce%29%29" class="RktValLink" data-pltdoc="x">namespace-syntax-introduce</a></span>, just as for
|
||
|
<span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._eval%29%29" class="RktValLink" data-pltdoc="x">eval</a></span>. Use <span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-~3edatum%29%29" class="RktValLink" data-pltdoc="x">syntax->datum</a></span> to convert the returned
|
||
|
syntax object into a printable datum.</p><p>If <span class="RktVar">insp</span> is not the original <a href="modprotect.html#%28tech._code._inspector%29" class="techoutside" data-pltdoc="x"><span class="techinside">code inspector</span></a> (i.e., the
|
||
|
value of <span class="RktPn">(</span><span class="RktSym"><a href="modprotect.html#%28def._%28%28quote._~23~25kernel%29._current-code-inspector%29%29" class="RktValLink" data-pltdoc="x">current-code-inspector</a></span><span class="RktPn">)</span> when Racket starts), then
|
||
|
the result syntax object is <a href="stxcerts.html#%28tech._tainted%29" class="techoutside" data-pltdoc="x"><span class="techinside">tainted</span></a>.</p><p>Here’s an example of using <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span> on a module:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><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><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><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><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Namespaces.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._make-base-namespace%29%29" class="RktValLink" data-pltdoc="x">make-base-namespace</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._datum-~3esyntax%29%29" class="RktValLink" data-pltdoc="x">datum->syntax</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">#f</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">module</span><span class="hspace"> </span><span class="RktVal">foo</span><span class="hspace"> </span><span class="RktVal">scheme</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">define</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">3</span><span class="RktVal">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVal">(</span><span class="RktVal">+</span><span class="hspace"> </span><span class="RktVal">a</span><span class="hspace"> </span><span class="RktVal">4</span><span class="RktVal">)</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>Here’s an example of using <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span> on a non-top-level form:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="Namespaces.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-namespace-anchor%29%29" class="RktStxLink" data-pltdoc="x">define-namespace-anchor</a></span><span class="hspace"> </span><span class="RktSym">anchor</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><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><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><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></td></tr><tr><td><span class="hspace"> &
|
||
|
<a href="syntax-model.html#%28tech._syntax._object%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax object</span></a>, and its lexical context is not enriched before
|
||
|
expansion.</div></p><p class="SHistory">Changed in version 8.2.0.4 of package <span class="stt">base</span>: Added the <span class="RktVar">insp</span> argument and tainting.</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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._expand-once))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-once%29%29" class="RktValDef RktValLink" data-pltdoc="x">expand-once</a></span></span><span class="hspace"> </span><span class="RktVar">top-level-form</span><span class="hspace"> </span><span class="RktOpt">[</span><span class="RktVar">insp</span><span class="RktOpt">]</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax~3f%29%29" class="RktValLink" data-pltdoc="x">syntax?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">top-level-form</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">insp</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="inspectors.html#%28def._%28%28quote._~23~25kernel%29._inspector~3f%29%29" class="RktValLink" data-pltdoc="x">inspector?</a></span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="modprotect.html#%28def._%28%28quote._~23~25kernel%29._current-code-inspector%29%29" class="RktValLink" data-pltdoc="x">current-code-inspector</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Partially expands <span class="RktVar">top-level-form</span> and returns a syntax object
|
||
|
for the partially-expanded expression. Due to limitations in the
|
||
|
expansion mechanism, some context information may be lost. In
|
||
|
particular, calling <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-once%29%29" class="RktValLink" data-pltdoc="x">expand-once</a></span> on the result may produce a
|
||
|
result that is different from expansion via <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span>.</div></p><p>Before <span class="RktVar">top-level-form</span> is expanded, its lexical context is
|
||
|
enriched with <span class="RktSym"><a href="Namespaces.html#%28def._%28%28quote._~23~25kernel%29._namespace-syntax-introduce%29%29" class="RktValLink" data-pltdoc="x">namespace-syntax-introduce</a></span>, as for
|
||
|
<span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._eval%29%29" class="RktValLink" data-pltdoc="x">eval</a></span>.</p><p>The <span class="RktVar">insp</span> argument determines whether the result is
|
||
|
<a href="stxcerts.html#%28tech._tainted%29" class="techoutside" data-pltdoc="x"><span class="techinside">tainted</span></a>, the same as for <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span>.</p><p class="SHistory">Changed in version 8.2.0.4 of package <span class="stt">base</span>: Added the <span class="RktVar">insp</span> argument and tainting.</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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._expand-syntax-once))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-syntax-once%29%29" class="RktValDef RktValLink" data-pltdoc="x">expand-syntax-once</a></span></span><span class="hspace"> </span><span class="RktVar">stx</span><span class="hspace"> </span><span class="RktOpt">[</span><span class="RktVar">insp</span><span class="RktOpt">]</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax~3f%29%29" class="RktValLink" data-pltdoc="x">syntax?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stx</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax~3f%29%29" class="RktValLink" data-pltdoc="x">syntax?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">insp</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="inspectors.html#%28def._%28%28quote._~23~25kernel%29._inspector~3f%29%29" class="RktValLink" data-pltdoc="x">inspector?</a></span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="modprotect.html#%28def._%28%28quote._~23~25kernel%29._current-code-inspector%29%29" class="RktValLink" data-pltdoc="x">current-code-inspector</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktPn">(</span><span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-once%29%29" class="RktValLink" data-pltdoc="x">expand-once</a></span><span class="stt"> </span><span class="RktVar">stx</span><span class="RktPn">)</span>, except that the argument
|
||
|
must be a <a href="syntax-model.html#%28tech._syntax._object%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax object</span></a>, and its lexical context is not
|
||
|
enriched before expansion.</div></p><p class="SHistory">Changed in version 8.2.0.4 of package <span class="stt">base</span>: Added the <span class="RktVar">insp</span> argument and tainting.</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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._expand-to-top-form))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-to-top-form%29%29" class="RktValDef RktValLink" data-pltdoc="x">expand-to-top-form</a></span></span><span class="hspace"> </span><span class="RktVar">top-level-form</span><span class="hspace"> </span><span class="RktOpt">[</span><span class="RktVar">insp</span><span class="RktOpt">]</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax~3f%29%29" class="RktValLink" data-pltdoc="x">syntax?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">top-level-form</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">insp</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="inspectors.html#%28def._%28%28quote._~23~25kernel%29._inspector~3f%29%29" class="RktValLink" data-pltdoc="x">inspector?</a></span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="modprotect.html#%28def._%28%28quote._~23~25kernel%29._current-code-inspector%29%29" class="RktValLink" data-pltdoc="x">current-code-inspector</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Partially expands <span class="RktVar">top-level-form</span> to reveal the outermost
|
||
|
syntactic form. This partial expansion is mainly useful for detecting
|
||
|
top-level uses of <span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29" class="RktStxLink" data-pltdoc="x">begin</a></span>. Unlike the result of
|
||
|
<span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-once%29%29" class="RktValLink" data-pltdoc="x">expand-once</a></span>, expanding the result of
|
||
|
<span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-to-top-form%29%29" class="RktValLink" data-pltdoc="x">expand-to-top-form</a></span> with <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span> produces the same
|
||
|
result as using <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span> on the original syntax.</div></p><p>Before <span class="RktSym">stx-or-sexpr</span> is expanded, its lexical context is
|
||
|
enriched with <span class="RktSym"><a href="Namespaces.html#%28def._%28%28quote._~23~25kernel%29._namespace-syntax-introduce%29%29" class="RktValLink" data-pltdoc="x">namespace-syntax-introduce</a></span>, as for
|
||
|
<span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._eval%29%29" class="RktValLink" data-pltdoc="x">eval</a></span>.</p><p>The <span class="RktVar">insp</span> argument determines whether the result is
|
||
|
<a href="stxcerts.html#%28tech._tainted%29" class="techoutside" data-pltdoc="x"><span class="techinside">tainted</span></a>, the same as for <span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand%29%29" class="RktValLink" data-pltdoc="x">expand</a></span>.</p><p class="SHistory">Changed in version 8.2.0.4 of package <span class="stt">base</span>: Added the <span class="RktVar">insp</span> argument and tainting.</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>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._expand-syntax-to-top-form))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-syntax-to-top-form%29%29" class="RktValDef RktValLink" data-pltdoc="x">expand-syntax-to-top-form</a></span></span><span class="hspace"> </span><span class="RktVar">stx</span><span class="hspace"> </span><span class="RktOpt">[</span><span class="RktVar">insp</span><span class="RktOpt">]</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax~3f%29%29" class="RktValLink" data-pltdoc="x">syntax?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">stx</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax~3f%29%29" class="RktValLink" data-pltdoc="x">syntax?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">insp</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="inspectors.html#%28def._%28%28quote._~23~25kernel%29._inspector~3f%29%29" class="RktValLink" data-pltdoc="x">inspector?</a></span><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="modprotect.html#%28def._%28%28quote._~23~25kernel%29._current-code-inspector%29%29" class="RktValLink" data-pltdoc="x">current-code-inspector</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktPn">(</span><span class="RktSym"><a href="Expanding_Top-Level_Forms.html#%28def._%28%28quote._~23~25kernel%29._expand-to-top-form%29%29" class="RktValLink" data-pltdoc="x">expand-to-top-form</a></span><span class="stt"> </span><span class="RktVar">stx</span><span class="RktPn">)</span>, except that the argument must
|
||
|
be a <a href="syntax-model.html#%28tech._syntax._object%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax object</span></a>, and its lexical context is not enriched
|
||
|
before expansion.</div></p><p class="SHistory">Changed in version 8.2.0.4 of package <span class="stt">base</span>: Added the <span class="RktVar">insp</span> argument and tainting.</p><h5 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-source-pkg="racket-doc" x-part-tag=""modinfo"">12.9.1<tt> </tt><a name="(part._modinfo)"></a>Information on Expanded Modules</h5><p>Information for an expanded <span class="RktSym"><a href="module.html#%28form._%28%28quote._~23~25kernel%29._module%29%29" class="RktStxLink" data-pltdoc="x">module</a></span> declaration is stored in a
|
||
|
set of <a href="stxprops.html#%28tech._syntax._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax properties</span></a> (see <a href="stxprops.html" data-pltdoc="x">Syntax Object Properties</a>) attached
|
||
|
to the syntax object:</p><ul><li><p><a name="(idx._(gentag._241._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">module-body-context</span> —<wbr></wbr> a syntax
|
||
|
object whose <a href="syntax-model.html#%28tech._lexical._information%29" class="techoutside" data-pltdoc="x"><span class="techinside">lexical information</span></a> corresponds to the inside of
|
||
|
the module, so it includes the expansion’s <a href="syntax-model.html#%28tech._outside._edge._scope%29" class="techoutside" data-pltdoc="x"><span class="techinside">outside-edge scope</span></a>
|
||
|
and its <a href="syntax-model.html#%28tech._inside._edge._scope%29" class="techoutside" data-pltdoc="x"><span class="techinside">inside-edge scope</span></a>; that is, the syntax object
|
||
|
simulates an identifier that is present in the original module body
|
||
|
and inaccessible to manipulation by any macro, so that its lexical
|
||
|
information includes bindings for the module’s imports and
|
||
|
definitions.</p><p class="SHistory">Added in version 6.4.0.1 of package <span class="stt">base</span>.</p></li><li><p><a name="(idx._(gentag._242._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">module-body-inside-context</span> —<wbr></wbr> a syntax
|
||
|
object whose <a href="syntax-model.html#%28tech._lexical._information%29" class="techoutside" data-pltdoc="x"><span class="techinside">lexical information</span></a> corresponds to an identifier
|
||
|
that starts with no lexical context and is moved into the macro, so
|
||
|
that it includes only the expansions’s <a href="syntax-model.html#%28tech._inside._edge._scope%29" class="techoutside" data-pltdoc="x"><span class="techinside">inside-edge scope</span></a>.</p><p class="SHistory">Added in version 6.4.0.1 of package <span class="stt">base</span>.</p></li><li><p><a name="(idx._(gentag._243._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">module-body-context-simple?</span> —<wbr></wbr> a boolean,
|
||
|
where <span class="RktVal">#t</span> indicates that the bindings of the module’s body
|
||
|
(as recorded in the <a href="syntax-model.html#%28tech._lexical._information%29" class="techoutside" data-pltdoc="x"><span class="techinside">lexical information</span></a> of the value of the
|
||
|
<span class="RktVal">'</span><span class="RktVal">module-body-inside-context</span> property) can be directly
|
||
|
reconstructed from modules directly imported into the module,
|
||
|
including imported for-syntax, for-meta, and for-template.</p><p class="SHistory">Added in version 6.4.0.1 of package <span class="stt">base</span>.</p></li></ul><p class="SHistory">Changed in version 7.0 of package <span class="stt">base</span>: Removed <span class="RktVal">'</span><span class="RktVal">module-variable-provides</span>,
|
||
|
<span class="RktVal">'</span><span class="RktVal">module-syntax-provides</span>,
|
||
|
<span class="RktVal">'</span><span class="RktVal">module-indirect-provides</span>,
|
||
|
and <span class="RktVal">'</span><span class="RktVal">module-indirect-for-meta-provides</span>
|
||
|
properties.</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, "8.6", "../");"/></form> <a href="https://docs.racket-lang.org/index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("8.6");">top</a><span class="tocsettoggle"> <a href="javascript:void(0);" title="show/hide table of contents" onclick="TocsetToggle();">contents</a></span></span><span class="navright"> <a href="stxcerts.html" title="backward to "12.8 Syntax Taints"" data-pltdoc="x">← prev</a> <a href="Macros.html" title="up to "12 Macros"" data-pltdoc="x">up</a> <a href="Serializing_Syntax.html" title="forward to "12.10 Serializing Syntax"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|