This file is indexed.

/usr/share/doc/racket/syntax/exprc.html is in racket-doc 6.1-4.

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
<!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>1.2.6&nbsp;Contracts on Macro Sub-expressions</title><link rel="stylesheet" type="text/css" href="../scribble.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="../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="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Syntax:<span class="mywbr"> &nbsp;</span> Meta-<wbr></wbr>Programming Helpers</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="stxparse.html" class="tocviewselflink" data-pltdoc="x">Parsing and Specifying Syntax</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="syntax-helpers.html" class="tocviewlink" data-pltdoc="x">Syntax Object Helpers</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="Datum_Pattern_Matching.html" class="tocviewlink" data-pltdoc="x">Datum Pattern Matching</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="module-helpers.html" class="tocviewlink" data-pltdoc="x">Module-<wbr></wbr>Processing Helpers</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="transformer-helpers.html" class="tocviewlink" data-pltdoc="x">Macro Transformer Helpers</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="reader-helpers.html" class="tocviewlink" data-pltdoc="x">Reader Helpers</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="Parsing_for_Bodies.html" class="tocviewlink" data-pltdoc="x">Parsing <span class="RktSym"><span class="RktStxLink">for</span></span> Bodies</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="Unsafe_for_Clause_Transforms.html" class="tocviewlink" data-pltdoc="x">Unsafe <span class="RktSym"><span class="RktStxLink">for</span></span> Clause Transforms</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="Source_Locations.html" class="tocviewlink" data-pltdoc="x">Source Locations</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="Preserving_Source_Locations.html" class="tocviewlink" data-pltdoc="x">Preserving Source Locations</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="toplevel.html" class="tocviewlink" data-pltdoc="x">Non-<wbr></wbr>Module Compilation And Expansion</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="trusted-xforms.html" class="tocviewlink" data-pltdoc="x">Trusting Standard Recertifying Transformers</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="docprovide.html" class="tocviewlink" data-pltdoc="x">Attaching Documentation to Exports</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,&quot;tocview_1&quot;);">&#9658;</a></td><td>1&nbsp;</td><td><a href="stxparse.html" class="tocviewlink" data-pltdoc="x">Parsing and Specifying Syntax</a></td></tr></table><div class="tocviewsublist" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">1.1&nbsp;</td><td><a href="stxparse-intro.html" class="tocviewlink" data-pltdoc="x">Introduction</a></td></tr><tr><td align="right">1.2&nbsp;</td><td><a href="stxparse-examples.html" class="tocviewselflink" data-pltdoc="x">Examples</a></td></tr><tr><td align="right">1.3&nbsp;</td><td><a href="Parsing_Syntax.html" class="tocviewlink" data-pltdoc="x">Parsing Syntax</a></td></tr><tr><td align="right">1.4&nbsp;</td><td><a href="stxparse-specifying.html" class="tocviewlink" data-pltdoc="x">Specifying Syntax with Syntax Classes</a></td></tr><tr><td align="right">1.5&nbsp;</td><td><a href="stxparse-patterns.html" class="tocviewlink" data-pltdoc="x">Syntax Patterns</a></td></tr><tr><td align="right">1.6&nbsp;</td><td><a href="Defining_Simple_Macros.html" class="tocviewlink" data-pltdoc="x">Defining Simple Macros</a></td></tr><tr><td align="right">1.7&nbsp;</td><td><a href="Literal_Sets_and_Conventions.html" class="tocviewlink" data-pltdoc="x">Literal Sets and Conventions</a></td></tr><tr><td align="right">1.8&nbsp;</td><td><a href="Library_Syntax_Classes_and_Literal_Sets.html" class="tocviewlink" data-pltdoc="x">Library Syntax Classes and Literal Sets</a></td></tr><tr><td align="right">1.9&nbsp;</td><td><a href="Debugging_and_Inspection_Tools.html" class="tocviewlink" data-pltdoc="x">Debugging and Inspection Tools</a></td></tr><tr><td align="right">1.10&nbsp;</td><td><a href="Experimental.html" class="tocviewlink" data-pltdoc="x">Experimental</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,&quot;tocview_2&quot;);">&#9660;</a></td><td>1.2&nbsp;</td><td><a href="stxparse-examples.html" class="tocviewlink" data-pltdoc="x">Examples</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">1.2.1&nbsp;</td><td><a href="Phases_and_Reusable_Syntax_Classes.html" class="tocviewlink" data-pltdoc="x">Phases and Reusable Syntax Classes</a></td></tr><tr><td align="right">1.2.2&nbsp;</td><td><a href="Optional_Keyword_Arguments.html" class="tocviewlink" data-pltdoc="x">Optional Keyword Arguments</a></td></tr><tr><td align="right">1.2.3&nbsp;</td><td><a href="uniform-meanings.html" class="tocviewlink" data-pltdoc="x">Variants with Uniform Meanings</a></td></tr><tr><td align="right">1.2.4&nbsp;</td><td><a href="varied-meanings.html" class="tocviewlink" data-pltdoc="x">Variants with Varied Meanings</a></td></tr><tr><td align="right">1.2.5&nbsp;</td><td><a href="More_Keyword_Arguments.html" class="tocviewlink" data-pltdoc="x">More Keyword Arguments</a></td></tr><tr><td align="right">1.2.6&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Contracts on Macro Sub-<wbr></wbr>expressions</a></td></tr></table></div></div></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, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="More_Keyword_Arguments.html" title="backward to &quot;1.2.5 More Keyword Arguments&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="stxparse-examples.html" title="up to &quot;1.2 Examples&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="Parsing_Syntax.html" title="forward to &quot;1.3 Parsing Syntax&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h5 x-source-module="(lib &quot;syntax/scribblings/syntax.scrbl&quot;)" x-part-tag="&quot;exprc&quot;">1.2.6<tt>&nbsp;</tt><a name="(part._exprc)"></a>Contracts on Macro Sub-expressions</h5><p>Just as procedures often expect certain kinds of values as arguments,
macros often have expectations about the expressions they are
given. And just as procedures express those expectations via
contracts, so can macros, using the <span class="RktSym"><a href="Library_Syntax_Classes_and_Literal_Sets.html#%28def._%28%28lib._syntax%2Fparse..rkt%29._expr%2Fc%29%29" class="RktValLink" data-pltdoc="x">expr/c</a></span> syntax class.</p><p>For example, here is a macro <span class="RktSym">myparameterize</span> that behaves like
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=parameters.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fmore-scheme..rkt%2529._parameterize%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">parameterize</a></span> but enforces the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=parameters.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._parameter%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">parameter?</a></span> contract on
the parameter expressions.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define-syntax%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define-syntax</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">myparameterize</span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="Parsing_Syntax.html#%28form._%28%28lib._syntax%2Fparse..rkt%29._syntax-parse%29%29" class="RktStxLink" data-pltdoc="x">syntax-parse</a></span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529.__%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">_</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">p</span><span class="hspace">&nbsp;</span><span class="RktSym">v:expr</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._......%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">body:expr</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:declare</span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="Library_Syntax_Classes_and_Literal_Sets.html#%28def._%28%28lib._syntax%2Fparse..rkt%29._expr%2Fc%29%29" class="RktValLink" data-pltdoc="x">expr/c</a></span><span class="hspace">&nbsp;</span><span class="RktRdr">#'</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=parameters.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._parameter%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">parameter?</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:name</span><span class="hspace">&nbsp;</span><span class="RktVal">"parameter argument"</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktRdr">#'</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=parameters.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fmore-scheme..rkt%2529._parameterize%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">parameterize</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">p.c</span><span class="hspace">&nbsp;</span><span class="RktSym">v</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=stx-patterns.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fstxcase-scheme..rkt%2529._......%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">...</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">body</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">myparameterize</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=port-ops.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._current-input-port%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">current-input-port</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=stringport.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._open-input-string%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">open-input-string</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"(1 2 3)"</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=Reading.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._read%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">read</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'(1<span class="stt"> </span>2<span class="stt"> </span>3)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">myparameterize</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVal">'</span><span class="RktVal">whoops</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">something</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktVal">'</span><span class="RktVal">whatever</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktErr">parameter argument of myparameterize: broke its contract</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">promised: parameter?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">produced: 'whoops</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: parameter?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">contract from: program</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">blaming: program</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">at: eval:61.0</span></p></td></tr></table></blockquote><p><span style="font-weight: bold">Important:</span> Make sure when using <span class="RktSym"><a href="Library_Syntax_Classes_and_Literal_Sets.html#%28def._%28%28lib._syntax%2Fparse..rkt%29._expr%2Fc%29%29" class="RktValLink" data-pltdoc="x">expr/c</a></span> to use the
<span class="RktSym">c</span> attribute. If the macro above had used <span class="RktSym">p</span> in the
template, the expansion would have used the raw, unchecked
expressions. The <span class="RktSym"><a href="Library_Syntax_Classes_and_Literal_Sets.html#%28def._%28%28lib._syntax%2Fparse..rkt%29._expr%2Fc%29%29" class="RktValLink" data-pltdoc="x">expr/c</a></span> syntax class does not change how
pattern variables are bound; it only computes an attribute that
represents the checked expression.</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, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="More_Keyword_Arguments.html" title="backward to &quot;1.2.5 More Keyword Arguments&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="stxparse-examples.html" title="up to &quot;1.2 Examples&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="Parsing_Syntax.html" title="forward to &quot;1.3 Parsing Syntax&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>