You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2 lines
133 KiB
HTML
2 lines
133 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"/><title>10 ◊ command overview</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="mb.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><script type="text/javascript" src="manual-racket.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-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">Pollen:<span class="mywbr"> </span> the book is a program</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="Installation.html" class="tocviewlink" data-pltdoc="x">Installation</a></td></tr><tr><td align="right">2 </td><td><a href="quick-tour.html" class="tocviewlink" data-pltdoc="x">Quick tour</a></td></tr><tr><td align="right">3 </td><td><a href="Backstory.html" class="tocviewlink" data-pltdoc="x">Backstory</a></td></tr><tr><td align="right">4 </td><td><a href="big-picture.html" class="tocviewlink" data-pltdoc="x">The big picture</a></td></tr><tr><td align="right">5 </td><td><a href="first-tutorial.html" class="tocviewlink" data-pltdoc="x">First tutorial</a></td></tr><tr><td align="right">6 </td><td><a href="second-tutorial.html" class="tocviewlink" data-pltdoc="x">Second tutorial</a></td></tr><tr><td align="right">7 </td><td><a href="third-tutorial.html" class="tocviewlink" data-pltdoc="x">Third tutorial</a></td></tr><tr><td align="right">8 </td><td><a href="raco-pollen.html" class="tocviewlink" data-pltdoc="x">Using <span class="stt">raco pollen</span></a></td></tr><tr><td align="right">9 </td><td><a href="File_formats.html" class="tocviewlink" data-pltdoc="x">File formats</a></td></tr><tr><td align="right">10 </td><td><a href="reader.html" class="tocviewselflink" data-pltdoc="x">◊ command overview</a></td></tr><tr><td align="right">11 </td><td><a href="Module_reference.html" class="tocviewlink" data-pltdoc="x">Module reference</a></td></tr><tr><td align="right">12 </td><td><a href="Acknowledgments.html" class="tocviewlink" data-pltdoc="x">Acknowledgments</a></td></tr><tr><td align="right">13 </td><td><a href="License___source_code.html" class="tocviewlink" data-pltdoc="x">License & source code</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>10 </td><td><a href="reader.html" class="tocviewselflink" data-pltdoc="x">◊ command overview</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">10.1 </td><td><a href="reader.html#%28part._.The_golden_rule%29" class="tocviewlink" data-pltdoc="x">The golden rule</a></td></tr><tr><td align="right">10.2 </td><td><a href="reader.html#%28part._.The_lozenge_glyph____%29" class="tocviewlink" data-pltdoc="x">The lozenge glyph (◊)</a></td></tr><tr><td align="right">10.3 </td><td><a href="reader.html#%28part._.The_two_command_modes__text_mode___.Racket_mode%29" class="tocviewlink" data-pltdoc="x">The two command modes:<span class="mywbr"> </span> text mode & Racket mode</a></td></tr><tr><td align="right">10.4 </td><td><a href="reader.html#%28part._.Further_reading%29" class="tocviewlink" data-pltdoc="x">Further reading</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">10.1<tt> </tt></span><a href="#%28part._.The_golden_rule%29" class="tocsubseclink" data-pltdoc="x">The golden rule</a></td></tr><tr><td><span class="tocsublinknumber">10.2<tt> </tt></span><a href="#%28part._.The_lozenge_glyph____%29" class="tocsubseclink" data-pltdoc="x">The lozenge glyph (◊)</a></td></tr><tr><td><span class="tocsublinknumber">10.3<tt> </tt></span><a href="#%28part._.The_two_command_modes__text_mode___.Racket_mode%29" class="tocsubseclink" data-pltdoc="x">The two command modes:<span class="mywbr"> </span> text mode & Racket mode</a></td></tr><tr><td><span class="tocsublinknumber">10.3.1<tt> </tt></span><a href="#%28part._.The_command_name%29" class="tocsubseclink" data-pltdoc="x">The command name</a></td></tr><tr><td><span class="tocsublinknumber">10.3.1.1<tt> </tt></span><a href="#%28part._.Invoking_tag_functions%29" class="tocsubseclink" data-pltdoc="x">Invoking tag functions</a></td></tr><tr><td><span class="tocsublinknumber">10.3.1.2<tt> </tt></span><a href="#%28part._.Invoking_other_functions%29" class="tocsubseclink" data-pltdoc="x">Invoking other functions</a></td></tr><tr><td><span class="tocsublinknumber">10.3.1.3<tt> </tt></span><a href="#%28part._.Inserting_the_value_of_a_variable%29" class="tocsubseclink" data-pltdoc="x">Inserting the value of a variable</a></td></tr><tr><td><span class="tocsublinknumber">10.3.1.4<tt> </tt></span><a href="#%28part._.Inserting_metas%29" class="tocsubseclink" data-pltdoc="x">Inserting metas</a></td></tr><tr><td><span class="tocsublinknumber">10.3.1.5<tt> </tt></span><a href="#%28part._.Inserting_a_comment%29" class="tocsubseclink" data-pltdoc="x">Inserting a comment</a></td></tr><tr><td><span class="tocsublinknumber">10.3.2<tt> </tt></span><a href="#%28part._.The_.Racket_arguments%29" class="tocsubseclink" data-pltdoc="x">The Racket arguments</a></td></tr><tr><td><span class="tocsublinknumber">10.3.3<tt> </tt></span><a href="#%28part._.The_text_argument%29" class="tocsubseclink" data-pltdoc="x">The text argument</a></td></tr><tr><td><span class="tocsublinknumber">10.4<tt> </tt></span><a href="#%28part._.Further_reading%29" class="tocsubseclink" data-pltdoc="x">Further reading</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.1.0.5</span></div><div class="navsettop"><span class="navleft"><div class="nosearchform"></div> </span><span class="navright"> <a href="File_formats.html" title="backward to "9 File formats"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Pollen: the book is a program"" data-pltdoc="x">up</a> <a href="Module_reference.html" title="forward to "11 Module reference"" data-pltdoc="x">next →</a></span> </div><h3>10<tt> </tt><a name="(part._reader)"></a>◊ command overview</h3><h4>10.1<tt> </tt><a name="(part._.The_golden_rule)"></a>The golden rule</h4><p>Pollen uses a special character — the <span style="font-style: italic">lozenge</span>, which looks like this: ◊ — to mark commands within a Pollen source file. So when you put a ◊ in your source, whatever comes next will be treated as a command. If you don’t, it will just be interpreted as plain text.</p><h4>10.2<tt> </tt><a name="(part._.The_lozenge_glyph____)"></a>The lozenge glyph (◊)</h4><p>I chose the lozenge as the command marker because a) it appears in almost every font, b) it’s barely used in ordinary typesetting, c) it’s not used in any programming language that I know of, and d) its shape and color allow it to stand out easily in code without being distracting.</p><p>Here’s how you type it:</p><p><span style="font-weight: bold">Mac</span>: option + shift + V</p><p><span style="font-weight: bold">Windows</span>: holding down alt, type 9674 on the num pad</p><p><span style="font-weight: bold">Ubuntu</span>: ctrl + shift + U, then 25CA</p><p>Still, if you don’t want to use the lozenge as your command marker, you can use something else. Set Pollen’s <span class="RktSym"><a href="World.html#%28def._%28%28lib._pollen%2Fworld..rkt%29._world~3acommand-marker%29%29" class="RktValLink" data-pltdoc="x">world:command-marker</a></span> value to whatever character you want.</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>Scribble uses the @ sign as a delimiter. It’s not a bad choice if you only work with Racket files. But as you use Pollen to work on other kinds of text-based files that commonly contain @ signs — HTML pages especially — it gets cumbersome. So I changed it.</p></blockquote></blockquote></blockquote><p>But don’t knock the lozenge till you try it.</p><h4>10.3<tt> </tt><a name="(part._.The_two_command_modes__text_mode___.Racket_mode)"></a>The two command modes: text mode & Racket mode</h4><p>Pollen commands can be entered in one of two modes: <span style="font-style: italic">text mode</span> or <span style="font-style: italic">Racket mode</span>. Both modes start with a lozenge (<span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span>):</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span><span class="hspace"> </span><span class="sroman">‹<span style="font-style: italic">command name</span>›</span><span class="hspace"> </span><span class="RktInBG"><span class="hspace"></span><span class="RktIn">[</span><span class="hspace"></span></span><span class="hspace"> </span><span class="sroman">‹<span style="font-style: italic">Racket arguments ...</span>›</span><span class="hspace"> </span><span class="RktInBG"><span class="hspace"></span><span class="RktIn">]</span><span class="hspace"></span></span><span class="hspace"> </span><span class="RktInBG"><span class="hspace"></span><span class="RktIn">{</span><span class="hspace"></span></span><span class="hspace"> </span><span class="sroman">‹<span style="font-style: italic">text argument</span>›</span><span class="hspace"> </span><span class="RktInBG"><span class="hspace"></span><span class="RktIn">}</span><span class="hspace"></span></span></td></tr><tr><td><span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span><span class="hspace"> </span><span class="RktInBG"><span class="hspace"></span><span class="RktIn">(</span><span class="hspace"></span></span><span class="hspace"> </span><span class="sroman">‹<span style="font-style: italic">Racket expression</span>›</span><span class="hspace"> </span><span class="RktInBG"><span class="hspace"></span><span class="RktIn">)</span><span class="hspace"></span></span></td></tr></table></blockquote><p><span style="font-weight: bold">Text-mode commands</span></p><p>A text-mode command has the three possible parts after the <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span>:</p><ul><li><p>The <span style="font-style: italic">command name</span> appears immediately after the <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span>. Typically it’s a short word.</p></li><li><p>The <span style="font-style: italic">Racket arguments</span> appear between square brackets. Pollen is partly an interface to the Racket programming language. These arguments are entered using Racket conventions — e.g., a <span class="stt">string of text</span> needs to be put in quotes as a <span class="RktVal">"string</span><span class="hspace"> </span><span class="RktVal">of</span><span class="hspace"> </span><span class="RktVal">text"</span><span class="RktMeta"></span>. If you like programming, you’ll end up using these frequently. If you don’t, you won’t.</p></li><li><p>The <span style="font-style: italic">text argument</span> appears between braces (aka curly brackets). You can put any ordinary text here. Unlike with the Racket arguments, you don’t put quotes around the text.</p></li></ul><p>Each of the three parts is optional. You can also nest commands within each other. However:</p><ul><li><p>You can never have spaces between the three parts.</p></li><li><p>Whatever parts you use must always appear in the order above.</p></li></ul><p>Here are a few examples of correct text-mode commands:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">variable-name</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._tag%29%29" class="RktStxLink" data-pltdoc="x">tag</a></span><span class="RktPn">{</span><span class="RktMeta">Text</span><span class="hspace"> </span><span class="RktMeta">inside</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">tag.</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._tag%29%29" class="RktStxLink" data-pltdoc="x">tag</a></span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">attr:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Text</span><span class="hspace"> </span><span class="RktMeta">inside</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">get-customer-id</span><span class="RktPn">[</span><span class="RktVal">"Brennan</span><span class="hspace"> </span><span class="RktVal">Huff"</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._tag%29%29" class="RktStxLink" data-pltdoc="x">tag</a></span><span class="RktPn">{</span><span class="RktMeta">His</span><span class="hspace"> </span><span class="RktMeta">ID</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">get-customer-id</span><span class="RktPn">[</span><span class="RktVal">"Brennan</span><span class="hspace"> </span><span class="RktVal">Huff"</span><span class="RktPn">]</span><span class="RktMeta">.</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><p>And some incorrect examples:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._tag%29%29" class="RktStxLink" data-pltdoc="x">tag</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">{</span><span class="RktMeta">Text</span><span class="hspace"> </span><span class="RktMeta">inside</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">tag.</span><span class="RktPn">}</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktCmt">;</span><span class="hspace"> </span><span class="RktCmt">space</span><span class="hspace"> </span><span class="RktCmt">between</span><span class="hspace"> </span><span class="RktCmt">first</span><span class="hspace"> </span><span class="RktCmt">and</span><span class="hspace"> </span><span class="RktCmt">second</span><span class="hspace"> </span><span class="RktCmt">parts</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._tag%29%29" class="RktStxLink" data-pltdoc="x">tag</a></span><span class="RktPn">[</span><span class="RktSym">Text</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">inside</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">the</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._tag%29%29" class="RktStxLink" data-pltdoc="x">tag</a></span><span class="RktPn">]</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktCmt">;</span><span class="hspace"> </span><span class="RktCmt">text</span><span class="hspace"> </span><span class="RktCmt">argument</span><span class="hspace"> </span><span class="RktCmt">needs</span><span class="hspace"> </span><span class="RktCmt">to</span><span class="hspace"> </span><span class="RktCmt">be</span><span class="hspace"> </span><span class="RktCmt">within</span><span class="hspace"> </span><span class="RktCmt">braces</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/creatingunits.html#%28form._%28%28lib._racket%2Funit..rkt%29._tag%29%29" class="RktStxLink" data-pltdoc="x">tag</a></span><span class="RktPn">{</span><span class="RktMeta">Text</span><span class="hspace"> </span><span class="RktMeta">inside</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktPn">[</span><span class="RktVal">'</span><span class="RktMeta">attr:</span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktCmt">;</span><span class="hspace"> </span><span class="RktCmt">wrong</span><span class="hspace"> </span><span class="RktCmt">order</span><span class="RktMeta"></span></td></tr></table></blockquote><p>The next section describes each of these parts in detail.</p><p><span style="font-weight: bold">Racket-mode commands</span></p><p>If you’re familiar with Racket expressions, you can use the Racket-mode commands to embed them within Pollen source files. It’s simple: any Racket expression can become a Pollen command by adding <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span> to the front. So in Racket, this code:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="http://docs.racket-lang.org/reference/index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">song</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Revolution"</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29" class="RktValLink" data-pltdoc="x">format</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"~a</span><span class="hspace"> </span><span class="RktVal">#~a"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">song</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr></table></blockquote><p>Can be converted to Pollen like so:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">song</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Revolution"</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29" class="RktValLink" data-pltdoc="x">format</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"~a</span><span class="hspace"> </span><span class="RktVal">#~a"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">song</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr></table></blockquote><p>And in DrRacket, they produce the same output:</p><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">Revolution #9</span></span></p></blockquote><p>Beyond that, there’s not much to say about Racket mode — any valid expression you can write in Racket will also be a valid Racket-mode Pollen command.</p><p><span style="font-weight: bold">The relationship of text mode and Racket mode</span></p><p>Even if you don’t plan to write a lot of Racket-mode commands, you should be aware that under the hood, Pollen is converting all commands in text mode to Racket mode. So a text-mode command that looks like this:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">◊</span><span class="RktSym">headline</span><span class="RktPn">[</span><span class="RktPn">#:size</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">enormous</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Man</span><span class="hspace"> </span><span class="RktMeta">Bites</span><span class="hspace"> </span><span class="RktMeta">Dog!</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><p>Is actually being turned into a Racket-mode command like this:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">headline</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">#:size</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">enormous</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Man</span><span class="hspace"> </span><span class="RktVal">Bites</span><span class="hspace"> </span><span class="RktVal">Dog!"</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr></table></blockquote><p>Thus a text-mode command is just an alternate way of writing a Racket-mode command. (More broadly, all of Pollen is just an alternate way of using Racket.)</p><p>The corollary is that you can always write Pollen commands using whichever mode is more convenient or readable. For instance, the earlier example, written in the Racket mode:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">song</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Revolution"</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29" class="RktValLink" data-pltdoc="x">format</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"~a</span><span class="hspace"> </span><span class="RktVal">#~a"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">song</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr></table></blockquote><p>Can be rewritten using text mode:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktPn">[</span><span class="RktSym">song</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Revolution</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29" class="RktValLink" data-pltdoc="x">format</a></span><span class="RktPn">[</span><span class="RktVal">"~a</span><span class="hspace"> </span><span class="RktVal">#~a"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">song</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr></table></blockquote><p>And it will work the same way.</p><h5>10.3.1<tt> </tt><a name="(part._.The_command_name)"></a>The command name</h5><p>In Pollen, you’ll typically use the command name for one of four purposes:</p><ul><li><p>To invoke a tag function.</p></li><li><p>To invoke another function.</p></li><li><p>To insert the value of a variable.</p></li><li><p>To insert a <span class="stt">meta</span> value.</p></li><li><p>To insert a comment.</p></li></ul><h5>10.3.1.1<tt> </tt><a name="(part._.Invoking_tag_functions)"></a>Invoking tag functions</h5><p>By default, Pollen treats every command name as a <span style="font-style: italic">tag function</span>. The default tag function creates a tagged X-expression with the command name as the tag, and the text argument as the content.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">strong</span><span class="RktPn">{</span><span class="RktMeta">Fancy</span><span class="hspace"> </span><span class="RktMeta">Sauce</span><span class="RktMeta">,</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">$1</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(strong "Fancy Sauce, $1")</span></span></p></blockquote><p>To streamline markup, Pollen doesn’t restrict you to a certain set of tags, nor does it make you define your tags ahead of time. Just type a tag, and you can start using it.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">utterlyridiculoustagname</span><span class="RktPn">{</span><span class="RktMeta">Oh</span><span class="hspace"> </span><span class="RktMeta">really?</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(utterlyridiculoustagname "Oh really?")</span></span></p></blockquote><p>The one restriction is that you can’t invent names for tags that are already being used for other commands. For instance, <span class="stt">map</span> is a name permanently reserved by the Racket function <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span>. It’s also a rarely-used HTML tag. But gosh, you really want to use it. Problem is, if you invoke it directly, Pollen will think you mean the other <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="RktPn">{</span><span class="RktMeta">Fancy</span><span class="hspace"> </span><span class="RktMeta">Sauce</span><span class="RktMeta">,</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">$1</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktErr"><span class="stt">map: arity mismatch;<br/>the expected number of arguments does not match the given number<br/>  given: 1<br/>  arguments...:<br/>    "Fancy Sauce, $1"</span></span></p></blockquote><p>What to do? Read on.</p><h5>10.3.1.2<tt> </tt><a name="(part._.Invoking_other_functions)"></a>Invoking other functions</h5><p>Though every command name starts out as a default tag function, it doesn’t necessarily end there. You have two options for invoking other functions: defining your own, or invoking others from Racket.</p><p><span style="font-weight: bold">Defining your own functions</span></p><p>Use the <span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span> command to create your own function for a command name. After that, when you use the command name, you’ll get the new behavior. For instance, recall this example showing the default tag-function behavior:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">strong</span><span class="RktPn">{</span><span class="RktMeta">Fancy</span><span class="hspace"> </span><span class="RktMeta">Sauce</span><span class="RktMeta">,</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">$1</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(strong "Fancy Sauce, $1")</span></span></p></blockquote><p>We can define <span class="stt">strong</span> to do something else, like add to the text:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">strong</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29" class="RktStxLink" data-pltdoc="x">`</a></span><span class="RktPn">(</span><span class="RktSym">strong</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28quote._~23~25kernel%29._unquote%29%29" class="RktStxLink" data-pltdoc="x">,</a></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29" class="RktValLink" data-pltdoc="x">format</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Hey!</span><span class="hspace"> </span><span class="RktVal">Listen</span><span class="hspace"> </span><span class="RktVal">up!</span><span class="hspace"> </span><span class="RktVal">~a"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">strong</span><span class="RktPn">{</span><span class="RktMeta">Fancy</span><span class="hspace"> </span><span class="RktMeta">Sauce</span><span class="RktMeta">,</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">$1</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(strong "Hey! Listen up! Fancy Sauce, $1")</span></span></p></blockquote><p>The replacement function has to accept any arguments that might get passed along, but it doesn’t have to do anything with them. For instance, this function definition won’t work because <span class="stt">strong</span> is going to get a text argument that it’s not defined to handle:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">strong</span><span class="RktPn">)</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktPn">(</span><span class="RktSym">fib</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"1</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">8</span><span class="hspace"> </span><span class="RktVal">13</span><span class="hspace"> </span><span class="RktVal">..."</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">strong</span><span class="RktPn">{</span><span class="RktMeta">Fancy</span><span class="hspace"> </span><span class="RktMeta">Sauce</span><span class="RktMeta">,</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">$1</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktErr"><span class="stt">strong: arity mismatch;<br/>the expected number of arguments does not match the given number<br/>  expected: 0<br/>  given: 1<br/>  arguments...:<br/>    "Fancy Sauce, $1"</span></span></p></blockquote><p>Whereas in this version, <span class="stt">strong</span> accepts an argument called <span class="stt">text</span>, but then ignores it:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">strong</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktPn">(</span><span class="RktSym">fib</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"1</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="hspace"> </span><span class="RktVal">3</span><span class="hspace"> </span><span class="RktVal">5</span><span class="hspace"> </span><span class="RktVal">8</span><span class="hspace"> </span><span class="RktVal">13</span><span class="hspace"> </span><span class="RktVal">..."</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">strong</span><span class="RktPn">{</span><span class="RktMeta">Fancy</span><span class="hspace"> </span><span class="RktMeta">Sauce</span><span class="RktMeta">,</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">$1</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(fib "1 1 2 3 5 8 13 ...")</span></span></p></blockquote><p>You can attach any behavior to a command name. As your project evolves, you can also update the behavior of a command name. In that way, Pollen commands become a set of hooks to which you can attach more elaborate processing.</p><p><span style="font-weight: bold">Using Racket functions</span></p><p>You aren’t limited to functions you define. Any function from Racket, or any Racket library, can be invoked directly by using it as a command name. Here’s the function <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._range%29%29" class="RktValLink" data-pltdoc="x">range</a></span>, which creates a list of numbers:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._range%29%29" class="RktValLink" data-pltdoc="x">range</a></span><span class="RktPn">[</span><span class="RktVal">1</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">20</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(range 1 20)</span></span></p></blockquote><p><div class="SIntrapara">Hold on — that’s not what we want. Where’s the list of numbers? The problem here is that we didn’t explicitly import the <a href="http://docs.racket-lang.org/reference/pairs.html#%28mod-path._racket%2Flist%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/list</span></a> library, which contains the definition for <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._range%29%29" class="RktValLink" data-pltdoc="x">range</a></span>. (If you need to find out what library contains a certain function, the Racket documentation will tell you.) Without <a href="http://docs.racket-lang.org/reference/pairs.html#%28mod-path._racket%2Flist%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/list</span></a>, Pollen just thinks we’re trying to use <span class="stt">range</span> as a tag function (and if we had been, then </div><div class="SIntrapara"><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(range 1 20)</span></span></p></blockquote></div><div class="SIntrapara"> would’ve been the right result).</div></p><p>We fix this by using the <span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span> command to bring in the <a href="http://docs.racket-lang.org/reference/pairs.html#%28mod-path._racket%2Flist%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/list</span></a> library, which contains the <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._range%29%29" class="RktValLink" data-pltdoc="x">range</a></span> we want:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">racket/list</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._range%29%29" class="RktValLink" data-pltdoc="x">range</a></span><span class="RktPn">[</span><span class="RktVal">1</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">20</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)</span></span></p></blockquote><p>Of course, you can also invoke Racket functions indirectly, by attaching them to functions you define for command names:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">racket/list</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">rick</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">start</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">finish</span><span class="RktPn">)</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._range%29%29" class="RktValLink" data-pltdoc="x">range</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">start</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">finish</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">rick</span><span class="RktPn">[</span><span class="RktVal">1</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">20</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19)</span></span></p></blockquote><p>Let’s return to the problem that surfaced in the last section — the fact that some command names can’t be used as tag functions because they’re already being used for other things. You can work around this by defining your own tag function with a non-conflicting name.</p><p>For instance, suppose we want to use <span class="stt">map</span> as a tag even though Racket is using it for its own function called <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span>. First, we invent a command name that doesn’t conflict. Let’s call it <span class="RktSym">my-map</span><span class="RktMeta"></span>. As you learned above, Pollen will treat a new command name as a tag function by default:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">my-map</span><span class="RktPn">{</span><span class="RktMeta">How</span><span class="hspace"> </span><span class="RktMeta">I</span><span class="hspace"> </span><span class="RktMeta">would</span><span class="hspace"> </span><span class="RktMeta">love</span><span class="hspace"> </span><span class="RktMeta">this</span><span class="hspace"> </span><span class="RktMeta">to</span><span class="hspace"> </span><span class="RktMeta">be</span><span class="hspace"> </span><span class="RktMeta">a</span><span class="hspace"> </span><span class="RktMeta">map.</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(my-map "How I would love this to be a map.")</span></span></p></blockquote><p>But <span class="RktSym">my-map</span><span class="RktMeta"></span> is not the tag we want. We need to define <span class="RktSym">my-map</span><span class="RktMeta"></span> to be a tag function for <span class="stt">map</span>. We can do this with the Pollen helper <span class="RktSym">make-default-tag-function</span>. That function lives in <span class="RktSym">pollen/tag</span>, so we <span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span> that too:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">pollen/tag</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">my-map</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">make-default-tag-function</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">my-map</span><span class="RktPn">{</span><span class="RktMeta">How</span><span class="hspace"> </span><span class="RktMeta">I</span><span class="hspace"> </span><span class="RktMeta">would</span><span class="hspace"> </span><span class="RktMeta">love</span><span class="hspace"> </span><span class="RktMeta">this</span><span class="hspace"> </span><span class="RktMeta">to</span><span class="hspace"> </span><span class="RktMeta">be</span><span class="hspace"> </span><span class="RktMeta">a</span><span class="hspace"> </span><span class="RktMeta">map.</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(map "How I would love this to be a map.")</span></span></p></blockquote><p>Problem solved.</p><h5>10.3.1.3<tt> </tt><a name="(part._.Inserting_the_value_of_a_variable)"></a>Inserting the value of a variable</h5><p>A Pollen command name usually refers to a function, but it can also refer to a <span style="font-style: italic">variable</span>, which is a data value. Once you define the variable, you can insert it into your source by using the ◊ notation without any other arguments:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">foo</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"bar"</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">foo</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">foo</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">The value of foo is bar</span></span></p></blockquote><p>Be careful — if you include arguments, even blank ones, Pollen will treat the command name as a function. This won’t work, because a variable is not a function:</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>To understand what happens here, recall the relationship between Pollen’s command modes. The text-mode command <span class="RktSym">◊foo</span><span class="RktPn">[</span><span class="RktPn">]</span><span class="RktMeta"></span> becomes the Racket-mode command <span class="RktPn">(</span><span class="RktSym">foo</span><span class="RktPn">)</span><span class="RktMeta"></span>, which after variable substitution becomes <span class="RktPn">(</span><span class="RktVal">"bar"</span><span class="RktPn">)</span><span class="RktMeta"></span>. If you try to evaluate <span class="RktPn">(</span><span class="RktVal">"bar"</span><span class="RktPn">)</span><span class="RktMeta"></span> — e.g., in DrRacket — you’ll get the same error.</p></blockquote></blockquote></blockquote><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">foo</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"bar"</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">foo</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">foo</span><span class="RktPn">[</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktErr"><span class="stt">application: not a procedure;<br/>expected a procedure that can be applied to arguments<br/>  given: "bar"<br/>  arguments...: [none]</span></span></p></blockquote><p>The reason we can simply drop <span class="RktSym">◊foo</span><span class="RktMeta"></span> into the text argument of another Pollen command is that the variable <span class="RktSym">foo</span><span class="RktMeta"></span> holds a string (i.e., a text value).</p><p>In preprocessor source files, Pollen will convert a variable to a string in a sensible way. For instance, numbers are easily converted:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">zam</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">42</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">zam</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">zam</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">The value of zam is 42</span></span></p></blockquote><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>In an unsaved DrRacket file, or a file without a special Pollen source extension, the <span class="stt">#lang pollen</span> designation invokes the Pollen preprocessor by default. You can explicitly invoke preprocessor mode by starting a file with <span class="stt">#lang pollen/pre</span>. See also <a href="File_formats.html#%28part._.Preprocessor___pp_extension_%29" data-pltdoc="x">Preprocessor (.pp extension)</a>.</p></blockquote></blockquote></blockquote><p>If the variable holds a container datatype (like a <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span>, <span class="RktSym"><a href="http://docs.racket-lang.org/reference/hashtables.html#%28def._%28%28quote._~23~25kernel%29._hash%29%29" class="RktValLink" data-pltdoc="x">hash</a></span>, or <span class="RktSym"><a href="http://docs.racket-lang.org/reference/vectors.html#%28def._%28%28quote._~23~25kernel%29._vector%29%29" class="RktValLink" data-pltdoc="x">vector</a></span>), Pollen will produce the Racket text representation of the item. Here, <span class="stt">zam</span> is a <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span> of integers:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">zam</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">1</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">2</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">zam</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">zam</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">The value of zam is '(1 2 3)</span></span></p></blockquote><p>This feature is included for your convenience. But in general, your readers won’t want to see the Racket representation of a container. So in these cases, you should convert to a string manually in some sensible way. Here, the integers in the list are converted to strings, which are then combined using <span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28lib._racket%2Fstring..rkt%29._string-join%29%29" class="RktValLink" data-pltdoc="x">string-join</a></span> from the <a href="http://docs.racket-lang.org/reference/strings.html#%28mod-path._racket%2Fstring%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/string</span></a> library:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">racket/string</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">zam</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">1</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">2</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">zam</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28lib._racket%2Fstring..rkt%29._string-join%29%29" class="RktValLink" data-pltdoc="x">string-join</a></span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28lib._racket%2Fprivate%2Fmap..rkt%29._map%29%29" class="RktValLink" data-pltdoc="x">map</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._number-~3estring%29%29" class="RktValLink" data-pltdoc="x">number->string</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">zam</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">and</span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">The value of zam is 1 and 2 and 3</span></span></p></blockquote><p>Pollen will still produce an error if you try to convert an esoteric value to a string. Here, <span class="stt">zam</span> is the addition function (<span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span>):</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">zam</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2B%29%29" class="RktValLink" data-pltdoc="x">+</a></span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">zam</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">zam</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktErr"><span class="stt">Pollen decoder: can't convert #<procedure:+> to string</span></span></p></blockquote><p>Moreover, Pollen will not perform <span style="font-style: italic">any</span> automatic text conversion in Pollen markup source files. Suppose we take the example above — which worked as a preprocessor source file — and change the language to <span class="RktSym">pollen/markup</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="File_formats.html#%28mod-path._pollen%2Fmarkup%29" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen/markup</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">zam</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">1</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">2</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">zam</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">zam</span><span class="RktMeta"></span></td></tr></table></blockquote><p>This time, the file will produce an error:</p><blockquote class="SubFlow"><p><span class="RktErr"><span class="stt">pollen markup error: in '(root "The value of zam is " (1 2 3)), '(1 2 3) is not a valid element (must be txexpr, string, symbol, XML char, or cdata)</span></span></p></blockquote><p>One special case to know about. In the examples above, there’s a word space between the variable and the other text. But suppose you need to insert a variable into text so that there’s no space in between. The simple ◊ notation won’t work, because it won’t be clear where the variable name ends and the text begins.</p><p>For instance, suppose we want to use a variable <span class="stt">edge</span> next to the string <span class="stt">px</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">edge</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">100</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">p</span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">{</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">margin-left:</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">edgepx</span><span class="RktCmt">;</span><span class="hspace"> </span><span class="RktCmt">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktErr"><span class="stt">Pollen decoder: can't convert #<procedure:...t/pollen/tag.rkt:6:2> to string</span></span></p></blockquote><p>The example fails because Pollen reads the whole string after the <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span> as the single variable name <span class="stt">edgepx</span>. Since <span class="stt">edgepx</span> isn’t defined, it’s treated as a tag function, and since Pollen can’t convert a function to a string, we get an error.</p><p>In these situations, surround the variable name with vertical bars <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊|</span><span class="hspace"></span></span>like so<span class="RktInBG"><span class="hspace"></span><span class="RktIn">|</span><span class="hspace"></span></span> to explicitly indicate where the variable name ends. The bars are not treated as part of the name, nor are they included in the result. Once we do that, we get what we intended:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">edge</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">100</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">p</span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">{</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">margin-left:</span><span class="hspace"> </span><span class="RktMeta">◊|</span><span class="RktSym">edge</span><span class="RktMeta">|px</span><span class="RktCmt">;</span><span class="hspace"> </span><span class="RktCmt">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">p { margin-left: 100px; }</span></span></p></blockquote><p>If you use this notation when you don’t need to, nothing bad will happen. The vertical bars are always ignored.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">edge</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">100</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">value</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">edge</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">◊|</span><span class="RktSym">edge</span><span class="RktMeta">|</span><span class="hspace"> </span><span class="RktMeta">pixels</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">The value of edge is 100 pixels</span></span></p></blockquote><h5>10.3.1.4<tt> </tt><a name="(part._.Inserting_metas)"></a>Inserting metas</h5><p><span style="font-style: italic">Metas</span> are key–value pairs embedded in a source file that are not included in the main output when the source is run, and collected into a separate hash table.</p><p>Metas are not a foundational abstraction. They’re just a convenience — a place to store arbitrary pieces of information that you might want to use later.</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>Pollen occasionally uses metas. For instance, the <span class="RktSym"><a href="Render.html#%28def._%28%28lib._pollen%2Frender..rkt%29._get-template-for%29%29" class="RktValLink" data-pltdoc="x">get-template-for</a></span> function will look in the metas of a source file to see if a template is explicitly specified. The <span class="RktSym">pollen/template</span> module also contains functions for working with metas, such as <span class="RktSym"><a href="Template.html#%28def._%28%28lib._pollen%2Ftemplate..rkt%29._select-from-metas%29%29" class="RktValLink" data-pltdoc="x">select-from-metas</a></span>.</p></blockquote></blockquote></blockquote><p>To insert a meta, use the standard command syntax for inserting a tag with an attribute pair, but use the special <span class="stt">meta</span> name:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"> </span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">some-tag</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">key:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Normal</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">meta</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">dog:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Roxy"</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">some-tag</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">key:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Another</span><span class="hspace"> </span><span class="RktMeta">normal</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><p>When you mark a meta like this, two things happen. First, when you run the file, the meta is removed from the result:</p><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(some-tag ((key "value")) "Normal tag")<br/><br/>'(some-tag ((key "value")) "Another normal tag")</span></span></p></blockquote><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>If your <span class="stt">meta</span> includes a text argument between curly braces — or any other arguments aside from the initial key–value pair — they will be ignored.</p></blockquote></blockquote></blockquote><p>Second, the meta is collected into a hash table that is exported with the name <span class="stt">metas</span>. To see this hash table, run the file above in DrRacket, then move to the interactions window and type <span class="stt">metas</span> at the prompt:</p><div class="terminal"><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">> metas</span></p></td></tr><tr><td><p><span class="stt">'#hash((here-path . "unsaved-editor167056") (dog . "Roxy"))</span></p></td></tr></table></div></div><p>The only key that’s automatically defined in every meta table is <span class="stt">here-path</span>, which is the absolute path to the source file. (Here, because the file hasn’t been saved, you’ll see the <span class="stt">unsaved-editor...</span> name instead.)</p><p>Still, you can override this too:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"> </span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">some-tag</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">key:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Normal</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">meta</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">dog:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Roxy"</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">some-tag</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">key:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Another</span><span class="hspace"> </span><span class="RktMeta">normal</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">meta</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">here-path:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"nowhere"</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr></table></blockquote><p>When you run this code, the result will be the same as before, but this time the metas will be different:</p><div class="terminal"><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">> metas</span></p></td></tr><tr><td><p><span class="stt">'#hash((dog . "Roxy") (here-path . "nowhere"))</span></p></td></tr></table></div></div><p>It doesn’t matter how many metas you put in a source file or where you put them. They’ll all be extracted and put into the <span class="stt">metas</span> hash table. The order of the metas is not preserved (because order is not preserved in a hash table). But if you have two metas with the same key, the later one will supersede the earlier one:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"> </span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">some-tag</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">key:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Normal</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">meta</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">dog:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Roxy"</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">some-tag</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">key:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"value"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Another</span><span class="hspace"> </span><span class="RktMeta">normal</span><span class="hspace"> </span><span class="RktMeta">tag</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">meta</span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">dog:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Lex"</span><span class="RktPn">]</span><span class="RktMeta"></span></td></tr></table></blockquote><p>Though there are two metas named <span class="RktVal">'</span><span class="RktVal">dog</span>, only the second one persists:</p><div class="terminal"><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p><span class="stt">> metas</span></p></td></tr><tr><td><p><span class="stt">'#hash((dog . "Lex") (here-path . "unsaved-editor167056"))</span></p></td></tr></table></div></div><h5>10.3.1.5<tt> </tt><a name="(part._.Inserting_a_comment)"></a>Inserting a comment</h5><p>Two options.</p><p>To comment out the rest of a single line, use a lozenge followed by a semicolon <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊;</span><span class="hspace"></span></span>.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">span</span><span class="RktPn">{</span><span class="RktMeta">This</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">not</span><span class="hspace"> </span><span class="RktMeta">a</span><span class="hspace"> </span><span class="RktMeta">comment</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">span</span><span class="RktPn">{</span><span class="RktMeta">Nor</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">this</span><span class="RktPn">}</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktCmt">;span{But</span><span class="hspace"> </span><span class="RktCmt">this</span><span class="hspace"> </span><span class="RktCmt">is}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(span "This is not a comment")<br/>'(span "Nor is this")</span></span></p></blockquote><p>To comment out a multiline block, use the lozenge–semicolon signal <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊;</span><span class="hspace"></span></span> with curly braces, <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊;{</span><span class="hspace"></span></span>like so<span class="RktInBG"><span class="hspace"></span><span class="RktIn">}</span><span class="hspace"></span></span>.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktCmt">;{</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊span</span><span class="RktPn">{</span><span class="RktMeta">This</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">not</span><span class="hspace"> </span><span class="RktMeta">a</span><span class="hspace"> </span><span class="RktMeta">comment</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊span</span><span class="RktPn">{</span><span class="RktMeta">Nor</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">this</span><span class="RktPn">}</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktCmt">;span{But</span><span class="hspace"> </span><span class="RktCmt">this</span><span class="hspace"> </span><span class="RktCmt">is}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"></span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">Actually</span><span class="RktMeta">,</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">it</span><span class="RktVal">'</span><span class="RktMeta">s</span><span class="hspace"> </span><span class="RktMeta">all</span><span class="hspace"> </span><span class="RktMeta">a</span><span class="hspace"> </span><span class="RktMeta">comment</span><span class="hspace"> </span><span class="RktMeta">now</span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">Actually, it's all a comment now</span></span></p></blockquote><h5>10.3.2<tt> </tt><a name="(part._.The_.Racket_arguments)"></a>The Racket arguments</h5><p>The middle part of a text-mode Pollen command contains the <span style="font-style: italic">Racket arguments</span> <span class="RktInBG"><span class="hspace"></span><span class="RktIn">[</span><span class="hspace"></span></span>between square brackets.<span class="RktInBG"><span class="hspace"></span><span class="RktIn">]</span><span class="hspace"></span></span> Most often, you’ll see these used to pass extra information to commands that operate on text.</p><p>For instance, tag functions. Recall from before that any not-yet-defined command name in Pollen is treated as a tag function:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/scribble/base.html#%28def._%28%28lib._scribble%2Fbase..rkt%29._title%29%29" class="RktValLink" data-pltdoc="x">title</a></span><span class="RktPn">{</span><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">Beginning</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">End</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(title "The Beginning of the End")</span></span></p></blockquote><p>But what if you wanted to add attributes to this tag, so that it comes out like this?</p><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(title ((class "red")(id "first")) "The Beginning of the End")</span></span></p></blockquote><p>You can do it with Racket arguments.</p><p>Here’s the hard way. You can type out your list of attributes in Racket format and drop them into the brackets as a single argument:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/scribble/base.html#%28def._%28%28lib._scribble%2Fbase..rkt%29._title%29%29" class="RktValLink" data-pltdoc="x">title</a></span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/createclass.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._class%29%29" class="RktStxLink" data-pltdoc="x">class</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"red"</span><span class="RktPn">)</span><span class="RktPn">(</span><span class="RktSym">id</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"first"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">Beginning</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">End</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(title ((class "red") (id "first")) "The Beginning of the End")</span></span></p></blockquote><p>But that’s a lot of parentheses to think about. So here’s the easy way. Anytime you use a tag function, there’s a shortcut for inserting attributes. You can enter them as a series of <span class="RktSym">symbol</span> / <span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string%29%29" class="RktValLink" data-pltdoc="x">string</a></span> pairs between the Racket-argument brackets. The only caveat is that the symbols have to begin with a quote mark <span class="RktInBG"><span class="hspace"></span><span class="RktIn">'</span><span class="hspace"></span></span> and end with a colon <span class="RktInBG"><span class="hspace"></span><span class="RktIn">:</span><span class="hspace"></span></span>. So taken together, they look like this:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/scribble/base.html#%28def._%28%28lib._scribble%2Fbase..rkt%29._title%29%29" class="RktValLink" data-pltdoc="x">title</a></span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">class:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"red"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">id:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"first"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">Beginning</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">End</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(title ((class "red") (id "first")) "The Beginning of the End")</span></span></p></blockquote><p>Racket arguments can be any valid Racket expressions. For instance, this will also work:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/scribble/base.html#%28def._%28%28lib._scribble%2Fbase..rkt%29._title%29%29" class="RktValLink" data-pltdoc="x">title</a></span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">class:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29" class="RktValLink" data-pltdoc="x">format</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"~a"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._%2A%29%29" class="RktValLink" data-pltdoc="x">*</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">6</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">7</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">id:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"first"</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">Beginning</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">End</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(title ((class "42") (id "first")) "The Beginning of the End")</span></span></p></blockquote><p>Since Pollen commands are really just Racket arguments underneath, you can use those too. Here, we’ll define a variable called <span class="stt">name</span> and use it in the Racket arguments of <span class="stt">title</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">name</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"Brennan"</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym"><a href="http://docs.racket-lang.org/scribble/base.html#%28def._%28%28lib._scribble%2Fbase..rkt%29._title%29%29" class="RktValLink" data-pltdoc="x">title</a></span><span class="RktPn">[</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">class:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"red"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quote.html#%28form._%28%28quote._~23~25kernel%29._quote%29%29" class="RktStxLink" data-pltdoc="x">'</a></span><span class="RktSym">id:</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">name</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">The</span><span class="hspace"> </span><span class="RktMeta">Beginning</span><span class="hspace"> </span><span class="RktMeta">of</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">End</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(title ((class "read") (id "Brennan")) "The Beginning of the End")</span></span></p></blockquote><p>You can also use this area for <span style="font-style: italic">keyword arguments</span>. Keyword arguments can be used to provide options for a particular Pollen command, to avoid redundancy. Suppose that instead of using the <span class="stt">h1 ... h6</span> tags, you want to consolidate them into one command called <span class="stt">heading</span> and select the level separately. You can do this with a keyword, in this case <span class="RktPn">#:level</span>, which is passed as a Racket argument:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">heading</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">#:level</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">which</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29" class="RktStxLink" data-pltdoc="x">`</a></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28quote._~23~25kernel%29._unquote%29%29" class="RktStxLink" data-pltdoc="x">,</a></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/symbols.html#%28def._%28%28quote._~23~25kernel%29._string-~3esymbol%29%29" class="RktValLink" data-pltdoc="x">string->symbol</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/Writing.html#%28def._%28%28quote._~23~25kernel%29._format%29%29" class="RktValLink" data-pltdoc="x">format</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">"h~a"</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">which</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28quote._~23~25kernel%29._unquote%29%29" class="RktStxLink" data-pltdoc="x">,</a></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"> </span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">heading</span><span class="RktPn">[</span><span class="RktPn">#:level</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">1</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Major</span><span class="hspace"> </span><span class="RktMeta">league</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">heading</span><span class="RktPn">[</span><span class="RktPn">#:level</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">2</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Minor</span><span class="hspace"> </span><span class="RktMeta">league</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">heading</span><span class="RktPn">[</span><span class="RktPn">#:level</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktVal">6</span><span class="RktPn">]</span><span class="RktPn">{</span><span class="RktMeta">Trivial</span><span class="hspace"> </span><span class="RktMeta">league</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(h1 "Major league")<br/>'(h2 "Minor league")<br/>'(h6 "Trivial league")</span></span></p></blockquote><h5>10.3.3<tt> </tt><a name="(part._.The_text_argument)"></a>The text argument</h5><p>The third part of a text-mode Pollen command is the text argument. The text argument <span class="RktInBG"><span class="hspace"></span><span class="RktIn">{</span><span class="hspace"></span></span>appears between curly braces<span class="RktInBG"><span class="hspace"></span><span class="RktIn">}</span><span class="hspace"></span></span>. It can contain any text you want. The text argument can also contain other Pollen commands with their own text arguments. And they can contain other Pollen commands ... and so on, all the way down.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">div</span><span class="RktPn">{</span><span class="RktMeta">Do</span><span class="hspace"> </span><span class="RktMeta">it</span><span class="hspace"> </span><span class="RktMeta">again.</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">div</span><span class="RktPn">{</span><span class="RktMeta">And</span><span class="hspace"> </span><span class="RktMeta">again.</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktSym">div</span><span class="RktPn">{</span><span class="RktMeta">And</span><span class="hspace"> </span><span class="RktMeta">yet</span><span class="hspace"> </span><span class="RktMeta">again.</span><span class="RktPn">}</span><span class="RktPn">}</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(div "Do it again. " (div "And again. " (div "And yet again.")))</span></span></p></blockquote><p>Three small details to know about the text argument.</p><p>First, the only character that needs special handling in a text argument is the lozenge <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊</span><span class="hspace"></span></span>. A lozenge ordinarily marks a new command. So if you want an actual lozenge to appear in the text, you have to escape it by typing <span class="RktInBG"><span class="hspace"></span><span class="RktIn">◊"◊"</span><span class="hspace"></span></span>.</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">definition</span><span class="RktPn">{</span><span class="RktMeta">This</span><span class="hspace"> </span><span class="RktMeta">is</span><span class="hspace"> </span><span class="RktMeta">the</span><span class="hspace"> </span><span class="RktMeta">lozenge:</span><span class="hspace"> </span><span class="RktMeta">◊</span><span class="RktVal">"◊"</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(definition "This is the lozenge: ◊")</span></span></p></blockquote><p>Second, the whitespace-trimming policy. Here’s the short version: if there’s a carriage return at either end of the text argument, it is trimmed, and whitespace at the end of each line is selectively trimmed in an intelligent way. So this text argument, with carriage returns on the ends:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">div</span><span class="RktPn">{</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">Roomy!</span></td></tr><tr><td><span class="RktMeta"> </span></td></tr><tr><td><span class="RktMeta">I</span><span class="hspace"> </span><span class="RktMeta">agree.</span></td></tr><tr><td><span class="RktMeta"></span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(div "Roomy!" "\n" "\n" "I agree.")</span></span></p></blockquote><p>Yields the same result as this one:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">div</span><span class="RktPn">{</span><span class="RktMeta">Roomy!</span></td></tr><tr><td><span class="RktMeta"> </span></td></tr><tr><td><span class="RktMeta">I</span><span class="hspace"> </span><span class="RktMeta">agree.</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(div "Roomy!" "\n" "\n" "I agree.")</span></span></p></blockquote><p>For the long version, please see [future link: Spaces, Newlines, and Indentation].</p><p>Third, within a multiline text argument, newline characters become individual strings that are not merged with adjacent text. So what you end up with is a list of strings, not a single string. That’s why in the last example, we got this:</p><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(div "Roomy!" "\n" "\n" "I agree.")</span></span></p></blockquote><p>Instead of this:</p><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(div "Roomy!\n\nI agree.")</span></span></p></blockquote><p>Under most circumstances, these two tagged X-expressions will behave the same way. The biggest exception is with functions. A function that operates on multiline text arguments needs to be able to handle an indefinite number of strings. For instance, this <span class="stt">jejune</span> function only accepts a single argument. It will work with a single-line text argument, because that produces a single string:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">jejune</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29" class="RktStxLink" data-pltdoc="x">`</a></span><span class="RktPn">(</span><span class="RktSym">jejune</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28quote._~23~25kernel%29._unquote%29%29" class="RktStxLink" data-pltdoc="x">,</a></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">jejune</span><span class="RktPn">{</span><span class="RktMeta">Irrational</span><span class="hspace"> </span><span class="RktMeta">confidence</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(jejune "Irrational confidence")</span></span></p></blockquote><p>But watch what happens with a multiline text argument:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">jejune</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29" class="RktStxLink" data-pltdoc="x">`</a></span><span class="RktPn">(</span><span class="RktSym">jejune</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28quote._~23~25kernel%29._unquote%29%29" class="RktStxLink" data-pltdoc="x">,</a></span><span class="RktSym">text</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">jejune</span><span class="RktPn">{</span><span class="RktMeta">Deeply</span></td></tr><tr><td><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">chastened</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktErr"><span class="stt">jejune: arity mismatch;<br/>the expected number of arguments does not match the given number<br/>  expected: 1<br/>  given: 3<br/>  arguments...:<br/>   "Deeply"<br/>   "\n"<br/>   "chastened"</span></span></p></blockquote><p>The answer is to use a <span style="font-style: italic">rest argument</span> in the function, which takes the “rest” of the arguments — however many there may be — and combines them into a single <span class="RktSym"><a href="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29" class="RktValLink" data-pltdoc="x">list</a></span>. If we rewrite <span class="stt">jejune</span> with a rest argument, we can fix the problem:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktMeta">#lang</span><span class="hspace"> </span><span class="RktMeta"></span><a href="index.html" class="RktModLink" data-pltdoc="x"><span class="RktSym">pollen</span></a><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktPn">(</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktPn">(</span><span class="RktSym">jejune</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktMeta">.</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym">texts</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._quasiquote%29%29" class="RktStxLink" data-pltdoc="x">`</a></span><span class="RktPn">(</span><span class="RktSym">jejune</span><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta"></span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/quasiquote.html#%28form._%28%28quote._~23~25kernel%29._unquote-splicing%29%29" class="RktStxLink" data-pltdoc="x">,@</a></span><span class="RktSym">texts</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktMeta"></span></td></tr><tr><td><span class="RktMeta">◊</span><span class="RktSym">jejune</span><span class="RktPn">{</span><span class="RktMeta">Deeply</span></td></tr><tr><td><span class="RktMeta"></span><span class="hspace"> </span><span class="RktMeta">chastened</span><span class="RktPn">}</span><span class="RktMeta"></span></td></tr></table></blockquote><blockquote class="SubFlow"><p><span class="RktVal"><span class="stt">'(jejune "Deeply" "\n" "chastened")</span></span></p></blockquote><h4>10.4<tt> </tt><a name="(part._.Further_reading)"></a>Further reading</h4><p>The Pollen language is a variant of Racket’s own text-processing language, called Scribble. So many things that are true about Scribble are also true about Pollen. For the sake of clarity & brevity, I’ve omitted them from this summary. But if you want the full story, see <a href="http://docs.racket-lang.org/scribble/reader.html" data-pltdoc="x">@ Syntax</a> in the Scribble documentation.</p><div class="navsetbottom"><span class="navleft"><div class="nosearchform"></div> </span><span class="navright"> <a href="File_formats.html" title="backward to "9 File formats"" data-pltdoc="x">← prev</a> <a href="index.html" title="up to "Pollen: the book is a program"" data-pltdoc="x">up</a> <a href="Module_reference.html" title="forward to "11 Module reference"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html> |