/usr/share/doc/racket/reference/stxprops.html is in racket-doc 6.7-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | <!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"/><title>12.7 Syntax Object Properties</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"><span style="font-weight: bold">The Racket Reference</span></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" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">▼</a></td><td>12 </td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">12.1 </td><td><a href="stx-patterns.html" class="tocviewlink" data-pltdoc="x">Pattern-<wbr></wbr>Based Syntax Matching</a></td></tr><tr><td align="right">12.2 </td><td><a href="stxops.html" class="tocviewlink" data-pltdoc="x">Syntax Object Content</a></td></tr><tr><td align="right">12.3 </td><td><a href="stxcmp.html" class="tocviewlink" data-pltdoc="x">Syntax Object Bindings</a></td></tr><tr><td align="right">12.4 </td><td><a href="stxtrans.html" class="tocviewlink" data-pltdoc="x">Syntax Transformers</a></td></tr><tr><td align="right">12.5 </td><td><a href="stxparam.html" class="tocviewlink" data-pltdoc="x">Syntax Parameters</a></td></tr><tr><td align="right">12.6 </td><td><a href="splicing.html" class="tocviewlink" data-pltdoc="x">Local Binding with Splicing Body</a></td></tr><tr><td align="right">12.7 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Syntax Object Properties</a></td></tr><tr><td align="right">12.8 </td><td><a href="stxcerts.html" class="tocviewlink" data-pltdoc="x">Syntax Taints</a></td></tr><tr><td align="right">12.9 </td><td><a href="Expanding_Top-Level_Forms.html" class="tocviewlink" data-pltdoc="x">Expanding Top-<wbr></wbr>Level Forms</a></td></tr><tr><td align="right">12.10 </td><td><a href="include.html" class="tocviewlink" data-pltdoc="x">File Inclusion</a></td></tr><tr><td align="right">12.11 </td><td><a href="syntax-util.html" class="tocviewlink" data-pltdoc="x">Syntax Utilities</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">syntax-<wbr></wbr>property</span></span></a></td></tr><tr><td><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property-preserved~3f%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">syntax-<wbr></wbr>property-<wbr></wbr>preserved?</span></span></a></td></tr><tr><td><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property-symbol-keys%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">syntax-<wbr></wbr>property-<wbr></wbr>symbol-<wbr></wbr>keys</span></span></a></td></tr><tr><td><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">syntax-<wbr></wbr>track-<wbr></wbr>origin</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="splicing.html" title="backward to "12.6 Local Binding with Splicing Body"" data-pltdoc="x">← prev</a> <a href="Macros.html" title="up to "12 Macros"" data-pltdoc="x">up</a> <a href="stxcerts.html" title="forward to "12.8 Syntax Taints"" data-pltdoc="x">next →</a></span> </div><h4 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-source-pkg="racket-doc" x-part-tag=""stxprops"">12.7<tt> </tt><a name="(part._stxprops)"></a>Syntax Object Properties</h4><p>Every syntax object has an associated <a name="(tech._syntax._property)"></a><span style="font-style: italic">syntax property</span> list,
which can be queried or extended with
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property%29%29" class="RktValLink" data-pltdoc="x">syntax-property</a></span>. A property is set as
<a name="(tech._stx._prop._preserved)"></a><span style="font-style: italic">preserved</span> or not; a preserved property is
maintained for a syntax object in a compiled form that is marshaled to a byte
string or <span class="stt">".zo"</span> file, and other properties are discarded when
marshaling.</p><p>In <span class="RktSym"><a href="Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax%29%29" class="RktValLink" data-pltdoc="x">read-syntax</a></span>, the reader attaches a preserved <span class="RktVal">'</span><span class="RktVal">paren-shape</span>
property to any pair or vector syntax object generated from parsing a
pair <span class="RktInBG"><span class="hspace"></span><span class="RktIn">[</span><span class="hspace"></span></span> and <span class="RktInBG"><span class="hspace"></span><span class="RktIn">]</span><span class="hspace"></span></span> or <span class="RktInBG"><span class="hspace"></span><span class="RktIn">{</span><span class="hspace"></span></span> and
<span class="RktInBG"><span class="hspace"></span><span class="RktIn">}</span><span class="hspace"></span></span>; the property value is <span class="RktVal">#\[</span> in the former case,
and <span class="RktVal">#\{</span> in the latter case. The <span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._syntax%29%29" class="RktStxLink" data-pltdoc="x">syntax</a></span> form copies
any <span class="RktVal">'</span><span class="RktVal">paren-shape</span> property from the source of a template to
corresponding generated syntax.</p><p>Both the syntax input to a transformer and the syntax result of a
transformer may have associated properties. The two sets of properties
are merged by the syntax expander: each property in the original and
not present in the result is copied to the result, and the values of
properties present in both are combined with <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span> (result
value first, original value second) and the <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span>ed value is
<a href="#%28tech._stx._prop._preserved%29" class="techoutside" data-pltdoc="x"><span class="techinside">preserved</span></a> if either of the values were
preserved.</p><p>Before performing the merge, however, the syntax expander
automatically adds a property to the original syntax object using the
key <a name="(idx._(gentag._192._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">origin</span>. If the source syntax has no
<span class="RktVal">'</span><span class="RktVal">origin</span> property, it is set to the empty list. Then, still
before the merge, the identifier that triggered the macro expansion
(as syntax) is <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29" class="RktValLink" data-pltdoc="x">cons</a></span>ed onto the <span class="RktVal">'</span><span class="RktVal">origin</span>
property so far. The <span class="RktVal">'</span><span class="RktVal">origin</span> property thus records (in
reverse order) the sequence of macro expansions that produced an
expanded expression. Usually, the <span class="RktVal">'</span><span class="RktVal">origin</span> value is a
list of identifiers. However, a transformer might return
syntax that has already been expanded, in which case an
<span class="RktVal">'</span><span class="RktVal">origin</span> list can contain other lists after a merge. The
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValLink" data-pltdoc="x">syntax-track-origin</a></span> procedure implements this tracking.
The <span class="RktVal">'</span><span class="RktVal">origin</span> property is added as
non-<a href="#%28tech._stx._prop._preserved%29" class="techoutside" data-pltdoc="x"><span class="techinside">preserved</span></a>.</p><p>Besides <span class="RktVal">'</span><span class="RktVal">origin</span> tracking for general macro expansion,
Racket adds properties to expanded syntax (often using
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValLink" data-pltdoc="x">syntax-track-origin</a></span>) to record additional expansion details:</p><ul><li><p>When 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 is spliced into a sequence with
internal definitions (see <a href="syntax-model.html#%28part._intdef-body%29" data-pltdoc="x">Internal Definitions</a>),
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValLink" data-pltdoc="x">syntax-track-origin</a></span> is applied to every spliced element from
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> body. The second argument to
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValLink" data-pltdoc="x">syntax-track-origin</a></span> is 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> form, and the
third argument is 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> keyword (extracted from the
spliced form).</p></li><li><p>When an internal <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> form is converted into a
<span class="RktSym"><a href="let.html#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29" class="RktStxLink" data-pltdoc="x">letrec-syntaxes+values</a></span> form (see <a href="syntax-model.html#%28part._intdef-body%29" data-pltdoc="x">Internal Definitions</a>),
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValLink" data-pltdoc="x">syntax-track-origin</a></span> is applied to each generated binding
clause. The second argument to <span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValLink" data-pltdoc="x">syntax-track-origin</a></span> is the
converted form, and the third argument is the <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> keyword form the converted form.</p></li><li><p>When a <span class="RktSym"><a href="let.html#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29" class="RktStxLink" data-pltdoc="x">letrec-syntaxes+values</a></span> expression is fully
expanded, syntax bindings disappear, and the result is either a
<span class="RktSym"><a href="let.html#%28form._%28%28quote._~23~25kernel%29._letrec-values%29%29" class="RktStxLink" data-pltdoc="x">letrec-values</a></span> form (if the unexpanded form contained
non-syntax bindings), or only the body of the
<span class="RktSym"><a href="let.html#%28form._%28%28quote._~23~25kernel%29._letrec-syntaxes%2Bvalues%29%29" class="RktStxLink" data-pltdoc="x">letrec-syntaxes+values</a></span> form (wrapped with <span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29" class="RktStxLink" data-pltdoc="x">begin</a></span> if
the body contained multiple expressions). To record the disappeared
syntax bindings, a property is added to the expansion result: an
immutable list of identifiers from the disappeared bindings, as a
<a name="(idx._(gentag._193._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">disappeared-binding</span> property.</p></li><li><p>When a subtyping <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> form is expanded, the
identifier used to reference the base type does not appear in the
expansion. Therefore, the <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> transformer adds the
identifier to the expansion result as a
<a name="(idx._(gentag._194._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">disappeared-use</span> property.</p></li><li><p>When a reference to an unexported or protected identifier from
a module is discovered, the <a name="(idx._(gentag._195._(lib._scribblings/reference/reference..scrbl)))"></a><span class="RktVal">'</span><span class="RktVal">protected</span> property is
added to the identifier with a <span class="RktVal">#t</span> value.</p></li><li><p>When <span class="RktSym"><a href="Reading.html#%28def._%28%28quote._~23~25kernel%29._read-syntax%29%29" class="RktValLink" data-pltdoc="x">read-syntax</a></span>
generates a syntax object, it attaches a property to the object
(using a private key) to mark the object as originating from a
read. The <span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-original~3f%29%29" class="RktValLink" data-pltdoc="x">syntax-original?</a></span> predicate looks for the property
to recognize such syntax objects. (See <a href="stxops.html" data-pltdoc="x">Syntax Object Content</a> for more
information.)</p></li></ul><p>See also <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?tag=%28part._%28.%27%28lib._scribblings%2Ftools%2Ftools..scrbl%29.%27._.%27.Syntax_.Properties_that_.Check_.Syntax_.Looks_.For.%27%29%29&version=6.7" class="Sq" data-pltdoc="x">Check Syntax</a>
for one client of the <span class="RktVal">'</span><span class="RktVal">disappeared-use</span> and <span class="RktVal">'</span><span class="RktVal">disappeared-binding</span>
properties.</p><p>See <a href="Expanding_Top-Level_Forms.html#%28part._modinfo%29" data-pltdoc="x">Information on Expanded Modules</a> for information about properties generated
by the expansion of a module declaration. See <span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._lambda%29%29" class="RktStxLink" data-pltdoc="x">lambda</a></span> and
<a href="syntax-model.html#%28part._infernames%29" data-pltdoc="x">Inferred Value Names</a> for information about properties recognized
when compiling a procedure. See <span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._current-compile%29%29" class="RktValLink" data-pltdoc="x">current-compile</a></span> for
information on properties and byte codes.</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)._syntax-property))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property%29%29" class="RktValDef RktValLink" data-pltdoc="x">syntax-property</a></span></span><span class="hspace"> </span><span class="RktVar">stx</span><span class="hspace"> </span><span class="RktVar">key</span><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>[<span class="RktVar">preserved?</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">key</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktVar">preserved?</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktSym"><a href="symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol-interned~3f%29%29" class="RktValLink" data-pltdoc="x">symbol-interned?</a></span><span class="RktPn">)</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><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</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">preserved?</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><span class="hspace"> </span>=<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29" class="RktValLink" data-pltdoc="x">eq?</a></span><span class="hspace"> </span><span class="RktVar">key</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">paren-shape</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property%29%29" class="RktValDef RktValLink" data-pltdoc="x">syntax-property</a></span></span><span class="hspace"> </span><span class="RktVar">stx</span><span class="hspace"> </span><span class="RktVar">key</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></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">key</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></table></blockquote></div><div class="SIntrapara">The three- or four-argument form extends <span class="RktVar">stx</span> by associating
an arbitrary property value <span class="RktVar">v</span> with the key <span class="RktVar">key</span>; the
result is a new syntax object with the association (while <span class="RktVar">stx</span>
itself is unchanged). The property is added as
<a href="#%28tech._stx._prop._preserved%29" class="techoutside" data-pltdoc="x"><span class="techinside">preserved</span></a> if <span class="RktVar">preserved?</span> is true, in
which case <span class="RktVar">key</span> must be an <a href="reader.html#%28tech._interned%29" class="techoutside" data-pltdoc="x"><span class="techinside">interned</span></a> symbol, and <span class="RktVar">v</span>
should be a value as described below that can be saved in marshaled bytecode.</div></p><p>The two-argument form returns an arbitrary property value associated
to <span class="RktVar">stx</span> with the key <span class="RktVar">key</span>, or <span class="RktVal">#f</span> if no value
is associated to <span class="RktVar">stx</span> for <span class="RktVar">key</span>.</p><p>To support marshaling to bytecode, a value for a preserved syntax
property must be a non-cyclic value that is either</p><ul><li><p>a <a href="pairs.html#%28tech._pair%29" class="techoutside" data-pltdoc="x"><span class="techinside">pair</span></a> containing allowed preserved-property values;</p></li><li><p>a <a href="vectors.html#%28tech._vector%29" class="techoutside" data-pltdoc="x"><span class="techinside">vector</span></a> (unmarshaled as immutable) containing allowed preserved-property values;</p></li><li><p>a <a href="boxes.html#%28tech._box%29" class="techoutside" data-pltdoc="x"><span class="techinside">box</span></a> (unmarshaled as immutable) containing allowed preserved-property values;</p></li><li><p>an immutable <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> structure containing allowed preserved-property values;</p></li><li><p>an immutable <a href="hashtables.html#%28tech._hash._table%29" class="techoutside" data-pltdoc="x"><span class="techinside">hash table</span></a> whose keys and values are allowed preserved-property values;</p></li><li><p>a <a href="syntax-model.html#%28tech._syntax._object%29" class="techoutside" data-pltdoc="x"><span class="techinside">syntax object</span></a>; or</p></li><li><p>an empty list, <a href="symbols.html#%28tech._symbol%29" class="techoutside" data-pltdoc="x"><span class="techinside">symbol</span></a>, <a href="numbers.html#%28tech._number%29" class="techoutside" data-pltdoc="x"><span class="techinside">number</span></a>, <a href="characters.html#%28tech._character%29" class="techoutside" data-pltdoc="x"><span class="techinside">character</span></a>,
<a href="strings.html#%28tech._string%29" class="techoutside" data-pltdoc="x"><span class="techinside">string</span></a>, <a href="bytestrings.html#%28tech._byte._string%29" class="techoutside" data-pltdoc="x"><span class="techinside">byte string</span></a>, or <a href="regexp.html#%28tech._regexp._value%29" class="techoutside" data-pltdoc="x"><span class="techinside">regexp
value</span></a>.</p></li></ul><p>Any other value for a preserved property triggers an exception at an
attempt to marshal the owning syntax object to bytecode form.</p><p class="SHistory">Changed in version 6.4.0.14 of package <span class="stt">base</span>: Added the <span class="RktVar">preserved?</span> argument.</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)._syntax-property-preserved~3f))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property-preserved~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">syntax-property-preserved?</a></span></span><span class="hspace"> </span><span class="RktVar">stx</span><span class="hspace"> </span><span class="RktVar">key</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</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">key</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span><span class="hspace"> </span><span class="RktSym"><a href="symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol-interned~3f%29%29" class="RktValLink" data-pltdoc="x">symbol-interned?</a></span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">stx</span> has a
<a href="#%28tech._stx._prop._preserved%29" class="techoutside" data-pltdoc="x"><span class="techinside">preserved</span></a> property value for <span class="RktVar">key</span>,
<span class="RktVal">#f</span> otherwise.</div></p><p class="SHistory">Added in version 6.4.0.14 of package <span class="stt">base</span>.</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)._syntax-property-symbol-keys))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-property-symbol-keys%29%29" class="RktValDef RktValLink" data-pltdoc="x">syntax-property-symbol-keys</a></span></span><span class="hspace"> </span><span class="RktVar">stx</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list~3f%29%29" class="RktValLink" data-pltdoc="x">list?</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></table></blockquote></div><div class="SIntrapara">Returns a list of all symbols that as keys have associated properties
in <span class="RktVar">stx</span>. <a href="symbols.html#%28tech._uninterned%29" class="techoutside" data-pltdoc="x"><span class="techinside">Uninterned</span></a> symbols (see <a href="symbols.html" data-pltdoc="x">Symbols</a>)
are not included in the result list.</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>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td valign="top"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._syntax-track-origin))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValDef RktValLink" data-pltdoc="x">syntax-track-origin</a></span></span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">new-stx</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">orig-stx</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">id-stx</span><span class="RktPn">)</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top">→</td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">new-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">orig-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">id-stx</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="stxops.html#%28def._%28%28lib._racket%2Fprivate%2Fstx..rkt%29._identifier~3f%29%29" class="RktValLink" data-pltdoc="x">identifier?</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Adds properties to <span class="RktVar">new-stx</span> in the same way that macro
expansion adds properties to a transformer result. In particular, it
merges the properties of <span class="RktVar">orig-stx</span> into <span class="RktVar">new-stx</span>,
first adding <span class="RktVar">id-stx</span> as an <span class="RktVal">'</span><span class="RktVal">origin</span> property, and it
returns the property-extended syntax object. Use the
<span class="RktSym"><a href="#%28def._%28%28quote._~23~25kernel%29._syntax-track-origin%29%29" class="RktValLink" data-pltdoc="x">syntax-track-origin</a></span> procedure in a macro transformer that
discards syntax (corresponding to <span class="RktVar">orig-stx</span> with a keyword
<span class="RktVar">id-stx</span>) leaving some other syntax in its place (corresponding
to <span class="RktVar">new-stx</span>).</div></p><p>For example, the expression</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span></p></blockquote><p>expands to</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let%29%29" class="RktStxLink" data-pltdoc="x">let</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">or-part</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktSym">or-part</span><span class="hspace"> </span><span class="RktSym">or-part</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote><p>which, in turn, expands to</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="let.html#%28form._%28%28quote._~23~25kernel%29._let-values%29%29" class="RktStxLink" data-pltdoc="x">let-values</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym">or-part</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktSym">or-part</span><span class="hspace"> </span><span class="RktSym">or-part</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote><p>The syntax object for the final expression will have an
<span class="RktVal">'</span><span class="RktVal">origin</span> property whose value is <span class="RktPn">(</span><span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Syntax_Quoting__quote-syntax.html#%28form._%28%28quote._~23~25kernel%29._quote-syntax%29%29" class="RktStxLink" data-pltdoc="x">quote-syntax</a></span><span class="stt"> </span><span class="RktSym"><a href="let.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._let%29%29" class="RktStxLink" data-pltdoc="x">let</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Syntax_Quoting__quote-syntax.html#%28form._%28%28quote._~23~25kernel%29._quote-syntax%29%29" class="RktStxLink" data-pltdoc="x">quote-syntax</a></span><span class="stt"> </span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="RktPn">)</span><span class="RktPn">)</span>.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.7", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.7");">top</a></span><span class="navright"> <a href="splicing.html" title="backward to "12.6 Local Binding with Splicing Body"" data-pltdoc="x">← prev</a> <a href="Macros.html" title="up to "12 Macros"" data-pltdoc="x">up</a> <a href="stxcerts.html" title="forward to "12.8 Syntax Taints"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|