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.
sugar/doc/Coercion.html

3 lines
87 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
11 years ago
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>2&nbsp;Coercion</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"/><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,&quot;tocview_0&quot;);">&#9660;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Sugar:<span class="mywbr"> &nbsp;</span> readability &amp; convenience library</a></td></tr></table></div><div class="tocviewsublisttop" style="display: block;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="Installation___updates.html" class="tocviewlink" data-pltdoc="x">Installation &amp; updates</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="Coercion.html" class="tocviewselflink" data-pltdoc="x">Coercion</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="Container.html" class="tocviewlink" data-pltdoc="x">Container</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="Debug.html" class="tocviewlink" data-pltdoc="x">Debug</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="File.html" class="tocviewlink" data-pltdoc="x">File</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="Len.html" class="tocviewlink" data-pltdoc="x">Len</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="License___source_code.html" class="tocviewlink" data-pltdoc="x">License &amp; 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,&quot;tocview_1&quot;);">&#9658;</a></td><td>2&nbsp;</td><td><a href="Coercion.html" class="tocviewselflink" data-pltdoc="x">Coercion</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">2.1&nbsp;</td><td><a href="Coercion.html#%28part._.Values%29" class="tocviewlink" data-pltdoc="x">Values</a></td></tr><tr><td align="right">2.2&nbsp;</td><td><a href="Coercion.html#%28part._.Coercion_contracts%29" class="tocviewlink" data-pltdoc="x">Coercion contracts</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">2.1<tt>&nbsp;</tt></span><a href="#%28part._.Values%29" class="tocsubseclink" data-pltdoc="x">Values</a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>&gt;</span>int</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>&gt;</span>string</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3esymbol%29%29" class="tocsubnonseclink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink"><span class="nobreak">-<wbr></wbr>&gt;</span>symbol</span></span></a></td></tr><tr><td><a
11 years ago
</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3eint%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-&gt;</span>int</a></span><span class="hspace">&nbsp;</span><span class="RktVal">#t</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">Can&#8217;t convert #t to integer</span></p></td></tr></table></blockquote></td></tr></table></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._sugar/coerce..rkt)._-~3estring))"></a><span title="Provided from: sugar/coerce | Package: sugar"><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValDef RktValLink" data-pltdoc="x"><span class="nobreak">-&gt;</span>string</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span>&rarr;<span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span></p></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">v</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://docs.racket-lang.org/reference/data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Return the most natural string representation of <span class="RktVar">v</span>, or raise an error if none exists.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-&gt;</span>string</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"string"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"string"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-&gt;</span>string</a></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">symbol</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"symbol"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-&gt;</span>string</a></span><span class="hspace">&nbsp;</span><span class="RktVal">98.6</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"98.6"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="Coercion.html#%28def._%28%28lib._sugar%2Fcoerce..rkt%29._-~3estring%29%29" class="RktValLink" data-pltdoc="x"><span class="nobreak">-&gt;</span>string</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a