This file is indexed.

/usr/share/doc/racket/guide/define-struct.html is in racket-doc 6.1-4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!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>5&nbsp;Programmer-Defined Datatypes</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="icons.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9660;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-weight: bold">The Racket Guide</span></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="intro.html" class="tocviewlink" data-pltdoc="x">Welcome to Racket</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="to-scheme.html" class="tocviewlink" data-pltdoc="x">Racket Essentials</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="datatypes.html" class="tocviewlink" data-pltdoc="x">Built-<wbr></wbr>In Datatypes</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="scheme-forms.html" class="tocviewlink" data-pltdoc="x">Expressions and Definitions</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Programmer-<wbr></wbr>Defined Datatypes</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="modules.html" class="tocviewlink" data-pltdoc="x">Modules</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="i_o.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="regexp.html" class="tocviewlink" data-pltdoc="x">Regular Expressions</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Exceptions and Control</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="for.html" class="tocviewlink" data-pltdoc="x">Iterations and Comprehensions</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="classes.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="units.html" class="tocviewlink" data-pltdoc="x">Units (Components)</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="reflection.html" class="tocviewlink" data-pltdoc="x">Reflection and Dynamic Evaluation</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="languages.html" class="tocviewlink" data-pltdoc="x">Creating Languages</a></td></tr><tr><td align="right">18&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Synchronization</a></td></tr><tr><td align="right">19&nbsp;</td><td><a href="performance.html" class="tocviewlink" data-pltdoc="x">Performance</a></td></tr><tr><td align="right">20&nbsp;</td><td><a href="parallelism.html" class="tocviewlink" data-pltdoc="x">Parallelism</a></td></tr><tr><td align="right">21&nbsp;</td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running and Creating Executables</a></td></tr><tr><td align="right">22&nbsp;</td><td><a href="More_Libraries.html" class="tocviewlink" data-pltdoc="x">More Libraries</a></td></tr><tr><td align="right">23&nbsp;</td><td><a href="dialects.html" class="tocviewlink" data-pltdoc="x">Dialects of Racket and Scheme</a></td></tr><tr><td align="right">24&nbsp;</td><td><a href="other-editors.html" class="tocviewlink" data-pltdoc="x">Command-<wbr></wbr>Line Tools and Your Editor of Choice</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9658;</a></td><td>5&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Programmer-<wbr></wbr>Defined Datatypes</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">5.1&nbsp;</td><td><a href="#%28part._.Simple_.Structure_.Types__struct%29" class="tocviewlink" data-pltdoc="x">Simple Structure Types:<span class="mywbr"> &nbsp;</span> <span class="RktSym"><span class="RktStxLink">struct</span></span></a></td></tr><tr><td align="right">5.2&nbsp;</td><td><a href="#%28part._struct-copy%29" class="tocviewlink" data-pltdoc="x">Copying and Update</a></td></tr><tr><td align="right">5.3&nbsp;</td><td><a href="#%28part._struct-subtypes%29" class="tocviewlink" data-pltdoc="x">Structure Subtypes</a></td></tr><tr><td align="right">5.4&nbsp;</td><td><a href="#%28part._trans-struct%29" class="tocviewlink" data-pltdoc="x">Opaque versus Transparent Structure Types</a></td></tr><tr><td align="right">5.5&nbsp;</td><td><a href="#%28part._struct-equal%29" class="tocviewlink" data-pltdoc="x">Structure Comparisons</a></td></tr><tr><td align="right">5.6&nbsp;</td><td><a href="#%28part._.Structure_.Type_.Generativity%29" class="tocviewlink" data-pltdoc="x">Structure Type Generativity</a></td></tr><tr><td align="right">5.7&nbsp;</td><td><a href="#%28part._prefab-struct%29" class="tocviewlink" data-pltdoc="x">Prefab Structure Types</a></td></tr><tr><td align="right">5.8&nbsp;</td><td><a href="#%28part._struct-options%29" class="tocviewlink" data-pltdoc="x">More Structure Type Options</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">5.1<tt>&nbsp;</tt></span><a href="#%28part._.Simple_.Structure_.Types__struct%29" class="tocsubseclink" data-pltdoc="x">Simple Structure Types:<span class="mywbr"> &nbsp;</span> <span class="RktSym"><span class="RktStxLink">struct</span></span></a></td></tr><tr><td><span class="tocsublinknumber">5.2<tt>&nbsp;</tt></span><a href="#%28part._struct-copy%29" class="tocsubseclink" data-pltdoc="x">Copying and Update</a></td></tr><tr><td><span class="tocsublinknumber">5.3<tt>&nbsp;</tt></span><a href="#%28part._struct-subtypes%29" class="tocsubseclink" data-pltdoc="x">Structure Subtypes</a></td></tr><tr><td><span class="tocsublinknumber">5.4<tt>&nbsp;</tt></span><a href="#%28part._trans-struct%29" class="tocsubseclink" data-pltdoc="x">Opaque versus Transparent Structure Types</a></td></tr><tr><td><span class="tocsublinknumber">5.5<tt>&nbsp;</tt></span><a href="#%28part._struct-equal%29" class="tocsubseclink" data-pltdoc="x">Structure Comparisons</a></td></tr><tr><td><span class="tocsublinknumber">5.6<tt>&nbsp;</tt></span><a href="#%28part._.Structure_.Type_.Generativity%29" class="tocsubseclink" data-pltdoc="x">Structure Type Generativity</a></td></tr><tr><td><span class="tocsublinknumber">5.7<tt>&nbsp;</tt></span><a href="#%28part._prefab-struct%29" class="tocsubseclink" data-pltdoc="x">Prefab Structure Types</a></td></tr><tr><td><span class="tocsublinknumber">5.8<tt>&nbsp;</tt></span><a href="#%28part._struct-options%29" class="tocsubseclink" data-pltdoc="x">More Structure Type Options</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="parameterize.html" title="backward to &quot;4.13 Dynamic Binding: parameterize&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="index.html" title="up to &quot;The Racket Guide&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="modules.html" title="forward to &quot;6 Modules&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h3 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;define-struct&quot;">5<tt>&nbsp;</tt><a name="(part._define-struct)"></a>Programmer-Defined Datatypes</h3><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="magnify.png" alt="+" width="24" height="24"/></span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=structures.html&amp;version=6.1" class="Sq" data-pltdoc="x">Structures</a> in <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=index.html&amp;version=6.1" class="Sq" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a> also documents structure types.</p></blockquote></blockquote></blockquote><p>New datatypes are normally created with the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span>
form, which is the topic of this chapter. The class-based object
system, which we defer to <a href="classes.html" data-pltdoc="x">Classes and Objects</a>, offers an alternate
mechanism for creating new datatypes, but even classes and objects are
implemented in terms of structure types.</p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;Simple_Structure_Types__struct&quot;">5.1<tt>&nbsp;</tt><a name="(part._.Simple_.Structure_.Types__struct)"></a>Simple Structure Types: <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span></h4><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="magnify.png" alt="+" width="24" height="24"/></span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html&amp;version=6.1" class="Sq" data-pltdoc="x">Defining Structure Types: <span class="RktSym"><span class="RktStxLink">struct</span></span></a> in <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=index.html&amp;version=6.1" class="Sq" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a> also documents <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span>.</p></blockquote></blockquote></blockquote><p>To a first approximation, the syntax of <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> is</p><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktVar">struct-id</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">field-id</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></blockquote><p><table cellspacing="0" cellpadding="0"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote></td></tr></table></p><p>The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> form binds <span class="RktVar">struct-id</span> and a number of
identifiers that are built from <span class="RktVar">struct-id</span> and the
<span class="RktVar">field-id</span>s:</p><ul><li><p><span class="RktVar">struct-id</span> : a <a name="(tech._constructor)"></a><span style="font-style: italic">constructor</span> function that
takes as many arguments as the number of <span class="RktVar">field-id</span>s,
and returns an instance of the structure type.</p><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">posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#&lt;posn&gt;</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktVar">struct-id</span><span class="RktSym">?</span> : a <a name="(tech._predicate)"></a><span style="font-style: italic">predicate</span>
function that takes a single argument and returns <span class="RktVal">#t</span>
if it is an instance of the structure type, <span class="RktVal">#f</span>
otherwise.</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">posn?</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">posn?</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktVar">struct-id</span><span class="RktSym">-</span><span class="RktVar">field-id</span> : for
each <span class="RktVar">field-id</span>, an <a name="(tech._accessor)"></a><span style="font-style: italic">accessor</span> that extracts
the value of the corresponding field from an instance of the
structure type.</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">posn-x</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">posn-y</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">2</span></p></td></tr></table></blockquote></td></tr></table></li><li><p><span class="RktSym">struct:</span><span class="RktVar">struct-id</span> : a
<a name="(tech._structure._type._descriptor)"></a><span style="font-style: italic">structure type descriptor</span>, which is a value that
represents the structure type as a first-class value (with
<span class="RktPn">#:super</span>, as discussed later in
<a href="#%28part._struct-options%29" data-pltdoc="x">More Structure Type Options</a>).</p></li></ul><p>A <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> form places no constraints on the kinds of
values that can appear for fields in an instance of the structure
type. For example, <span class="RktPn">(</span><span class="RktSym">posn</span><span class="stt"> </span><span class="RktVal">"apple"</span><span class="stt"> </span><span class="RktVal">#f</span><span class="RktPn">)</span> produces an
instance of <span class="RktSym">posn</span>, even though <span class="RktVal">"apple"</span> and
<span class="RktVal">#f</span> are not valid coordinates for the obvious uses of
<span class="RktSym">posn</span> instances. Enforcing constraints on field values, such
as requiring them to be numbers, is normally the job of a contract, as
discussed later in <a href="contracts.html" data-pltdoc="x">Contracts</a>.</p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;struct-copy&quot;">5.2<tt>&nbsp;</tt><a name="(part._struct-copy)"></a>Copying and Update</h4><p>The <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=struct-copy.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct-copy%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct-copy</a></span> form clones a structure and optionally
updates specified fields in the clone. This process is sometimes
called a <a name="(tech._functional._update)"></a><span style="font-style: italic">functional update</span>, because the result is a
structure with updated field values. but the original structure is not
modified.</p><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=struct-copy.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct-copy%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct-copy</a></span><span class="hspace">&nbsp;</span><span class="RktVar">struct-id</span><span class="hspace">&nbsp;</span><span class="RktVar">struct-expr</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktVar">field-id</span><span class="hspace">&nbsp;</span><span class="RktVar">expr</span><span class="RktPn">]</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></blockquote><p>The <span class="RktVar">struct-id</span> that appears after <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=struct-copy.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct-copy%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct-copy</a></span> must
be a structure type name bound by <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> (i.e., the
name that cannot be used directly as an expression). The
<span class="RktVar">struct-expr</span> must produce an instance of the structure type.
The result is a new instance of the structure type that is like the old
one, except that the field indicated by each <span class="RktVar">field-id</span> gets
the value of the corresponding <span class="RktVar">expr</span>.</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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p1</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p2</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=struct-copy.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct-copy%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct-copy</a></span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktSym">p1</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn-x</span><span class="hspace">&nbsp;</span><span class="RktSym">p2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn-y</span><span class="hspace">&nbsp;</span><span class="RktSym">p2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(3 2)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn-x</span><span class="hspace">&nbsp;</span><span class="RktSym">p1</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">posn-x</span><span class="hspace">&nbsp;</span><span class="RktSym">p2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'(1 3)</span></p></td></tr></table></blockquote></td></tr></table></p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;struct-subtypes&quot;">5.3<tt>&nbsp;</tt><a name="(part._struct-subtypes)"></a>Structure Subtypes</h4><p>An extended form of <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> can be used to define a
<span style="font-style: italic">structure subtype</span>, which is a structure type that extends an
existing structure type:</p><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktVar">struct-id</span><span class="hspace">&nbsp;</span><span class="RktVar">super-id</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">field-id</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></blockquote><p>The <span class="RktVar">super-id</span> must be a structure type name bound by
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> (i.e., the name that cannot be used directly as
an expression).</p><p><table cellspacing="0" cellpadding="0"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">3d-posn</span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">z</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr></table></p><p>A structure subtype inherits the fields of its supertype, and the
subtype constructor accepts the values for the subtype fields after
values for the supertype fields. An instance of a structure subtype
can be used with the predicate and accessors of the
supertype.</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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">3d-posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">p</span></td></tr><tr><td><p><span class="RktRes">#&lt;3d-posn&gt;</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">posn?</span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">posn-x</span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">3d-posn-z</span><span class="hspace">&nbsp;</span><span class="RktSym">p</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr></table></blockquote></td></tr></table></p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;trans-struct&quot;">5.4<tt>&nbsp;</tt><a name="(part._trans-struct)"></a>Opaque versus Transparent Structure Types</h4><p>With a structure type definition like</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote><p>an instance of the structure type prints in a way that does not show
any information about the fields&rsquo; values. That is, structure types by
default are <a name="(tech._opaque)"></a><span style="font-style: italic">opaque</span>. If the accessors and mutators of a
structure type are kept private to a module, then no other module can
rely on the representation of the type&rsquo;s instances.</p><p>To make a structure type <a name="(tech._transparent)"></a><span style="font-style: italic">transparent</span>, use the
<span class="RktPn">#:transparent</span> keyword after the field-name sequence:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:transparent</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(posn 1 2)</span></p></td></tr></table></td></tr></table></blockquote><p>An instance of a transparent structure type prints like a call to the
constructor, so that it shows the structures field values. A
transparent structure type also allows reflective operations, such as
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=structutils.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._struct%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">struct?</a></span> and <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=inspectors.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._struct-info%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">struct-info</a></span>, to be used on its instances
(see <a href="reflection.html" data-pltdoc="x">Reflection and Dynamic Evaluation</a>).</p><p>Structure types are opaque by default, because opaque structure
instances provide more encapsulation guarantees. That is, a library
can use an opaque structure to encapsulate data, and clients of the
library cannot manipulate the data in the structure except as allowed
by the library.</p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;struct-equal&quot;">5.5<tt>&nbsp;</tt><a name="(part._struct-equal)"></a>Structure Comparisons</h4><p>A generic <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span> comparison automatically recurs on the
fields of a transparent structure type, but <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span> defaults
to mere instance identity for opaque structure types:</p><p><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">glass</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">width</span><span class="hspace">&nbsp;</span><span class="RktSym">height</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:transparent</span><span class="RktPn">)</span></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">glass</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">glass</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">width</span><span class="hspace">&nbsp;</span><span class="RktSym">height</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">slab</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">slab</span><span class="hspace">&nbsp;</span><span class="RktSym">slab</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">slab</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></td></tr></table></blockquote></div></p><p>To support instances comparisons via <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span> without making
the structure type transparent, you can use the <span class="RktPn">#:methods</span>
keyword, <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._gen%7E3aequal%252Bhash%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">gen:equal+hash</a></span>, and implement three methods:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">width</span><span class="hspace">&nbsp;</span><span class="RktSym">height</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:methods</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._gen%7E3aequal%252Bhash%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">gen:equal+hash</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">equal-proc</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="hspace">&nbsp;</span><span class="RktSym">equal?-recur</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">compare </span><span class="RktSym">a</span><span class="RktCmt"> and </span><span class="RktSym">b</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._and%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">equal?-recur</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-width</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-width</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">equal?-recur</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-height</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-height</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">hash-proc</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">hash-recur</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">compute primary hash code of </span><span class="RktSym">a</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">hash-recur</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-width</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252A%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">hash-recur</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-height</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">hash2-proc</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">hash2-recur</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">compute secondary hash code of </span><span class="RktSym">a</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252B%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">+</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">hash2-recur</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-width</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">hash2-recur</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead-height</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr></table></td></tr></table></blockquote><p>The first function in the list implements the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span> test on
two <span class="RktSym">lead</span>s; the third argument to the function is used instead
of <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._equal%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">equal?</a></span> for recursive equality testing, so that data cycles
can be handled correctly. The other two functions compute primary and
secondary hash codes for use with <a href="hash-tables.html#%28tech._hash._table%29" class="techoutside" data-pltdoc="x"><span class="techinside">hash tables</span></a>:</p><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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">h</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=hashtables.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._make-hash%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">make-hash</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=hashtables.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._hash-set%2521%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hash-set!</a></span><span class="hspace">&nbsp;</span><span class="RktSym">h</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=hashtables.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._hash-ref%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hash-ref</a></span><span class="hspace">&nbsp;</span><span class="RktSym">h</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">3</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=hashtables.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._hash-ref%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">hash-ref</a></span><span class="hspace">&nbsp;</span><span class="RktSym">h</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">lead</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">hash-ref: no value found for key</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">key: #&lt;lead&gt;</span></p></td></tr></table></blockquote><p>The first function provided with <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=booleans.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._gen%7E3aequal%252Bhash%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">gen:equal+hash</a></span> is not
required to recursively compare the fields of the structure. For
example, a structure type representing a set might implement equality
by checking that the members of the set are the same, independent of
the order of elements in the internal representation. Just take care
that the hash functions produce the same value for any two structure
types that are supposed to be equivalent.</p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;Structure_Type_Generativity&quot;">5.6<tt>&nbsp;</tt><a name="(part._.Structure_.Type_.Generativity)"></a>Structure Type Generativity</h4><p>Each time that a <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> form is evaluated, it
generates a structure type that is distinct from all existing
structure types, even if some other structure type has the same name
and fields.</p><p>This generativity is useful for enforcing abstractions and
implementing programs such as interpreters, but beware of placing a
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> form in positions that are evaluated multiple
times.</p><p><div class="SIntrapara"><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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">add-bigger-fish</span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">fish</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">size</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:transparent</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">new every time</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._cond%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">null?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">fish</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._else%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">fish</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252A%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">fish-size</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._car%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">car</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td> </td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">add-bigger-fish</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(list (fish 1))</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">add-bigger-fish</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">add-bigger-fish</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">fish-size: contract violation;</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr">given value instantiates a different structure type with</span></p></td></tr><tr><td><p><span class="RktErr">the same name</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: fish?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: (fish 1)</span></p></td></tr></table></blockquote></td></tr></table></div><div class="SIntrapara"><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">fish</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">size</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:transparent</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">add-bigger-fish</span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._cond%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">null?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">fish</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._else%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._cons%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">cons</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">fish</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=generic-numbers.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._%252A%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">*</a></span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">fish-size</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._car%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">car</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">lst</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">add-bigger-fish</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">add-bigger-fish</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._null%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">null</a></span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(list (fish 2) (fish 1))</span></p></td></tr></table></td></tr></table></blockquote></div></p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;prefab-struct&quot;">5.7<tt>&nbsp;</tt><a name="(part._prefab-struct)"></a>Prefab Structure Types</h4><p>Although a <a href="#%28tech._transparent%29" class="techoutside" data-pltdoc="x"><span class="techinside">transparent</span></a> structure type prints in a way that
shows its content, the printed form of the structure cannot be used in
an expression to get the structure back, unlike the printed form of a
number, string, symbol, or list.</p><p>A <a name="(tech._prefab)"></a><span style="font-style: italic">prefab</span> (&ldquo;previously fabricated&rdquo;) structure type is a
built-in type that is known to the Racket printer and expression
reader. Infinitely many such types exist, and they are indexed by
name, field count, supertype, and other such details. The printed form
of a prefab structure is similar to a vector, but it starts
<span class="RktInBG"><span class="hspace"></span><span class="RktIn">#s</span><span class="hspace"></span></span> instead of just <span class="RktInBG"><span class="hspace"></span><span class="RktIn">#</span><span class="hspace"></span></span>, and the first element in the
printed form is the prefab structure type&rsquo;s name.</p><p>The following examples show instances of the <span class="RktSym">sprout</span>
prefab structure type that has one field. The first instance has a
field value <span class="RktVal">'</span><span class="RktVal">bean</span>, and the second has field value
<span class="RktVal">'</span><span class="RktVal">alfalfa</span>:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktVal">'</span><span class="RktVal">#s</span><span class="RktVal">(</span><span class="RktVal">sprout</span><span class="hspace">&nbsp;</span><span class="RktVal">bean</span><span class="RktVal">)</span></td></tr><tr><td><p><span class="RktRes">'#s(sprout bean)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktVal">'</span><span class="RktVal">#s</span><span class="RktVal">(</span><span class="RktVal">sprout</span><span class="hspace">&nbsp;</span><span class="RktVal">alfalfa</span><span class="RktVal">)</span></td></tr><tr><td><p><span class="RktRes">'#s(sprout alfalfa)</span></p></td></tr></table></blockquote><p>Like numbers and strings, prefab structures are &ldquo;self-quoting,&rdquo; so
the quotes above are optional:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktVal">#s</span><span class="RktVal">(</span><span class="RktVal">sprout</span><span class="hspace">&nbsp;</span><span class="RktVal">bean</span><span class="RktVal">)</span></td></tr><tr><td><p><span class="RktRes">'#s(sprout bean)</span></p></td></tr></table></blockquote><p>When you use the <span class="RktPn">#:prefab</span> keyword with
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span>, instead of generating a new structure type,
you obtain bindings that work with the existing prefab structure type:</p><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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">lunch</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">#s</span><span class="RktVal">(</span><span class="RktVal">sprout</span><span class="hspace">&nbsp;</span><span class="RktVal">bean</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">sprout</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">kind</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">sprout?</span><span class="hspace">&nbsp;</span><span class="RktSym">lunch</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">sprout-kind</span><span class="hspace">&nbsp;</span><span class="RktSym">lunch</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'bean</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">sprout</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">garlic</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#s(sprout garlic)</span></p></td></tr></table></blockquote><p>The field name <span class="RktSym">kind</span> above does not matter for finding
the prefab structure type; only the name <span class="RktSym">sprout</span> and the
number of fields matters. At the same time, the prefab structure type
<span class="RktSym">sprout</span> with three fields is a different structure type
than the one with a single field:</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">sprout?</span><span class="hspace">&nbsp;</span><span class="RktVal">#s</span><span class="RktVal">(</span><span class="RktVal">sprout</span><span class="hspace">&nbsp;</span><span class="RktVal">bean</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="hspace">&nbsp;</span><span class="RktVal">17</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">sprout</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">kind</span><span class="hspace">&nbsp;</span><span class="RktSym">yummy?</span><span class="hspace">&nbsp;</span><span class="RktSym">count</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:prefab</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">redefine</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">sprout?</span><span class="hspace">&nbsp;</span><span class="RktVal">#s</span><span class="RktVal">(</span><span class="RktVal">sprout</span><span class="hspace">&nbsp;</span><span class="RktVal">bean</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="hspace">&nbsp;</span><span class="RktVal">17</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">sprout?</span><span class="hspace">&nbsp;</span><span class="RktSym">lunch</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#f</span></p></td></tr></table></blockquote><p>A prefab structure type can have another prefab structure type as its
supertype, it can have mutable fields, and it can have auto
fields. Variations in any of these dimensions correspond to different
prefab structure types, and the printed form of the structure type&rsquo;s
name encodes all of the relevant details.</p><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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">building</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">rooms</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">location</span><span class="hspace">&nbsp;</span><span class="RktPn">#:mutable</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:prefab</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">house</span><span class="hspace">&nbsp;</span><span class="RktSym">building</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">occupied</span><span class="hspace">&nbsp;</span><span class="RktPn">#:auto</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:prefab</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:auto-value</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">no</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">house</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">factory</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'#s((house (1 no) building 2 #(1)) 5 factory no)</span></p></td></tr></table></blockquote><p>Every <a href="#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> structure type is <a href="#%28tech._transparent%29" class="techoutside" data-pltdoc="x"><span class="techinside">transparent</span></a>&#8212;<wbr></wbr>but even
less abstract than a <a href="#%28tech._transparent%29" class="techoutside" data-pltdoc="x"><span class="techinside">transparent</span></a> type, because instances can be
created without any access to a particular structure-type declaration
or existing examples. Overall, the different options for structure
types offer a spectrum of possibilities from more abstract to more
convenient:</p><ul><li><p><a href="#%28tech._opaque%29" class="techoutside" data-pltdoc="x"><span class="techinside">Opaque</span></a> (the default) : Instances cannot be inspected or
forged without access to the structure-type declaration. As
discussed in the next section, <a href="#%28tech._constructor._guard%29" class="techoutside" data-pltdoc="x"><span class="techinside">constructor guards</span></a> and
<a href="#%28tech._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">properties</span></a> can be attached to the structure type to
further protect or to specialize the behavior of its
instances.</p></li><li><p><a href="#%28tech._transparent%29" class="techoutside" data-pltdoc="x"><span class="techinside">Transparent</span></a> : Anyone can inspect or create an instance
without access to the structure-type declaration, which means
that the value printer can show the content of an instance. All
instance creation passes through a <a href="#%28tech._constructor._guard%29" class="techoutside" data-pltdoc="x"><span class="techinside">constructor guard</span></a>,
however, so that the content of an instance can be controlled,
and the behavior of instances can be specialized through
<a href="#%28tech._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">properties</span></a>. Since the structure type is generated by its
definition, instances cannot be manufactured simply through the
name of the structure type, and therefore cannot be generated
automatically by the expression reader. </p></li><li><p><a href="#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">Prefab</span></a> : Anyone can inspect or create an instance at any
time, without prior access to a structure-type declaration or
an example instance. Consequently, the expression reader can
manufacture instances directly. The instance cannot have a
<a href="#%28tech._constructor._guard%29" class="techoutside" data-pltdoc="x"><span class="techinside">constructor guard</span></a> or <a href="#%28tech._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">properties</span></a>.</p></li></ul><p>Since the expression reader can generate <a href="#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> instances, they
are useful when convenient <a href="serialization.html#%28tech._serialization%29" class="techoutside" data-pltdoc="x"><span class="techinside">serialization</span></a> is more important than
abstraction. <a href="#%28tech._opaque%29" class="techoutside" data-pltdoc="x"><span class="techinside">Opaque</span></a> and <a href="#%28tech._transparent%29" class="techoutside" data-pltdoc="x"><span class="techinside">transparent</span></a> structures also can
be serialized, however, if they are defined with
<span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=serialization.html%23%2528form._%2528%2528lib._racket%252Fserialize..rkt%2529._serializable-struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">serializable-struct</a></span> as described in
<a href="serialization.html" data-pltdoc="x">Datatypes and Serialization</a>.</p><h4 x-source-module="(lib &quot;scribblings/guide/guide.scrbl&quot;)" x-part-tag="&quot;struct-options&quot;">5.8<tt>&nbsp;</tt><a name="(part._struct-options)"></a>More Structure Type Options</h4><p>The full syntax of <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span> supports many options, both
at the structure-type level and at the level of individual fields:</p><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktVar">struct-id</span><span class="hspace">&nbsp;</span><span class="RktVar">maybe-super</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">field</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktVar">struct-option</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&nbsp;</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">maybe-super</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td></td></tr></table></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">super-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">field</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktVar">field-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt">&nbsp;</span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktVar">field-id</span><span class="hspace">&nbsp;</span><span class="RktVar">field-option</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">]</span></td></tr></table></td></tr></table></blockquote></blockquote><p>A <span class="RktVar">struct-option</span> always starts with a keyword:</p><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:mutable</span></td></tr></table></blockquote><p>Causes all fields of the structure to be mutable, and introduces
 for each <span class="RktVar">field-id</span> a <a name="(tech._mutator)"></a><span style="font-style: italic">mutator</span>
  <span class="RktSym">set-</span><span class="RktVar">struct-id</span><span class="RktSym">-</span><span class="RktVar">field-id</span><span class="RktSym">!</span>
 that sets the value of the corresponding field in an instance of
 the structure type.</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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">dot</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:mutable</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">d</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">dot</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td> </td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">dot-x</span><span class="hspace">&nbsp;</span><span class="RktSym">d</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">1</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">set-dot-x!</span><span class="hspace">&nbsp;</span><span class="RktSym">d</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">dot-x</span><span class="hspace">&nbsp;</span><span class="RktSym">d</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">10</span></p></td></tr></table></blockquote></td></tr></table><p>The <span class="RktPn">#:mutable</span> option can also be used as a
<span class="RktVar">field-option</span>, in which case it makes an individual field
mutable.</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="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">person</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">name</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">age</span><span class="hspace">&nbsp;</span><span class="RktPn">#:mutable</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">friend</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">person</span><span class="hspace">&nbsp;</span><span class="RktVal">"Barney"</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td> </td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">set-person-age!</span><span class="hspace">&nbsp;</span><span class="RktSym">friend</span><span class="hspace">&nbsp;</span><span class="RktVal">6</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">set-person-name!</span><span class="hspace">&nbsp;</span><span class="RktSym">friend</span><span class="hspace">&nbsp;</span><span class="RktVal">"Mary"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">set-person-name!: undefined;</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr">cannot reference undefined identifier</span></p></td></tr></table></blockquote></td></tr></table></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:transparent</span></td></tr></table></blockquote><p>Controls reflective access to structure instances, as discussed
in a previous section, <a href="#%28part._trans-struct%29" data-pltdoc="x">Opaque versus Transparent Structure Types</a>.</p></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:inspector</span><span class="hspace">&nbsp;</span><span class="RktVar">inspector-expr</span></td></tr></table></blockquote><p>Generalizes <span class="RktPn">#:transparent</span> to support more controlled access
to reflective operations.</p></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:prefab</span></td></tr></table></blockquote><p>Accesses a built-in structure type, as discussed
in a previous section, <a href="#%28part._prefab-struct%29" data-pltdoc="x">Prefab Structure Types</a>.</p></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:auto-value</span><span class="hspace">&nbsp;</span><span class="RktVar">auto-expr</span></td></tr></table></blockquote><p>Specifies a value to be used for all automatic fields in the
structure type, where an automatic field is indicated by the
<span class="RktPn">#:auto</span> field option. The constructor procedure does not
accept arguments for automatic fields. Automatic fields are
implicitly mutable (via reflective operations), but mutator
functions are bound only if <span class="RktPn">#:mutator</span> is also specified.</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktSym">y</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktSym">z</span><span class="hspace">&nbsp;</span><span class="RktPn">#:auto</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:transparent</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:auto-value</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(posn 1 2 0)</span></p></td></tr></table></blockquote></td></tr></table></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:guard</span><span class="hspace">&nbsp;</span><span class="RktVar">guard-expr</span></td></tr></table></blockquote><p> Specifies a
 <a name="(tech._constructor._guard)"></a><span style="font-style: italic">constructor guard</span> procedure to be called whenever an
 instance of the structure type is created. The guard takes as many
 arguments as non-automatic fields in the structure type, plus one
 more for the name of the instantiated type (in case a sub-type is
 instantiated, in which case it&rsquo;s best to report an error using the
 sub-type&rsquo;s name). The guard should return the same number of values
 as given, minus the name argument. The guard can raise an exception
 if one of the given arguments is unacceptable, or it can convert an
 argument.</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">thing</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">name</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:transparent</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:guard</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">name</span><span class="hspace">&nbsp;</span><span class="RktSym">type-name</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._cond%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">cond</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">string?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">name</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">name</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">name</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=symbols.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._symbol-%7E3estring%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">symbol-&gt;string</a></span><span class="hspace">&nbsp;</span><span class="RktSym">name</span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._else%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">else</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=exns.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._error%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktSym">type-name</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktVal">"bad name: ~e"</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">name</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">thing</span><span class="hspace">&nbsp;</span><span class="RktVal">"apple"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(thing "apple")</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">thing</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">apple</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(thing "apple")</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">thing</span><span class="hspace">&nbsp;</span><span class="RktVal">1/2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">thing: bad name: 1/2</span></p></td></tr></table></blockquote></td></tr></table><p>The guard is called even when subtype instances are created. In that
 case, only the fields accepted by the constructor are provided to
 the guard (but the subtype&rsquo;s guard gets both the original fields and
 fields added by the subtype).</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">person</span><span class="hspace">&nbsp;</span><span class="RktSym">thing</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">age</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:transparent</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:guard</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">name</span><span class="hspace">&nbsp;</span><span class="RktSym">age</span><span class="hspace">&nbsp;</span><span class="RktSym">type-name</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=if.html%23%2528form._%2528%2528quote._%7E23%7E25kernel%2529._if%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">if</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=number-types.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._negative%7E3f%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">negative?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">age</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=exns.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._error%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktSym">type-name</span><span class="hspace">&nbsp;</span><span class="RktVal">"bad age: ~e"</span><span class="hspace">&nbsp;</span><span class="RktSym">age</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=values.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._values%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">values</a></span><span class="hspace">&nbsp;</span><span class="RktSym">name</span><span class="hspace">&nbsp;</span><span class="RktSym">age</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">person</span><span class="hspace">&nbsp;</span><span class="RktVal">"John"</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(person "John" 10)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">person</span><span class="hspace">&nbsp;</span><span class="RktVal">"Mary"</span><span class="hspace">&nbsp;</span><span class="RktVal"><span class="nobreak">-1</span></span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">person: bad age: -1</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">person</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">person: bad name: 10</span></p></td></tr></table></blockquote></td></tr></table></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:methods</span><span class="hspace">&nbsp;</span><span class="RktVar">interface-expr</span><span class="hspace">&nbsp;</span><span class="RktPn">[</span><span class="RktVar">body</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">]</span></td></tr></table></blockquote><p>Associates method definitions for the structure type that correspond
to a <span style="font-style: italic">generic interface</span>.  For example, implementing the
methods for <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=dicts.html%23%2528form._%2528%2528lib._racket%252Fdict..rkt%2529._gen%7E3adict%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">gen:dict</a></span> allows instances of a structure
type to be used as dictionaries. Implementing
the methods for <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=Printer_Extension.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._gen%7E3acustom-write%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">gen:custom-write</a></span> allows the customization
of how an instance of a structure type is <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._display%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">display</a></span>ed.</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">cake</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">candles</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:methods</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=Printer_Extension.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._gen%7E3acustom-write%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">gen:custom-write</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">write-proc</span><span class="hspace">&nbsp;</span><span class="RktSym">cake</span><span class="hspace">&nbsp;</span><span class="RktSym">port</span><span class="hspace">&nbsp;</span><span class="RktSym">mode</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">cake-candles</span><span class="hspace">&nbsp;</span><span class="RktSym">cake</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">show</span><span class="hspace">&nbsp;</span><span class="RktVal">"</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktVal">~a</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktVal">~n"</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktVal">#\.</span><span class="hspace">&nbsp;</span><span class="RktSym">port</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">show</span><span class="hspace">&nbsp;</span><span class="RktVal">" .-~a-. ~n"</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktVal">#\|</span><span class="hspace">&nbsp;</span><span class="RktSym">port</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">show</span><span class="hspace">&nbsp;</span><span class="RktVal">" | ~a | ~n"</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktVal">#\space</span><span class="hspace">&nbsp;</span><span class="RktSym">port</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">show</span><span class="hspace">&nbsp;</span><span class="RktVal">"---~a---~n"</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktVal">#\-</span><span class="hspace">&nbsp;</span><span class="RktSym">port</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">show</span><span class="hspace">&nbsp;</span><span class="RktSym">fmt</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktSym">ch</span><span class="hspace">&nbsp;</span><span class="RktSym">port</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._fprintf%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">fprintf</a></span><span class="hspace">&nbsp;</span><span class="RktSym">port</span><span class="hspace">&nbsp;</span><span class="RktSym">fmt</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._make-string%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">make-string</a></span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="hspace">&nbsp;</span><span class="RktSym">ch</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=Writing.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._display%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">display</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">cake</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td><p><span class="RktOut"></span><span class="hspace">&nbsp;</span><span class="RktOut"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktOut">..... </span><span class="hspace">&nbsp;&nbsp;</span><span class="RktOut"></span></p></td></tr><tr><td><p><span class="RktOut"></span><span class="hspace">&nbsp;</span><span class="RktOut">.-|||||-. </span></p></td></tr><tr><td><p><span class="RktOut"></span><span class="hspace">&nbsp;</span><span class="RktOut">| </span><span class="hspace">&nbsp;&nbsp;</span><span class="RktOut"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktOut"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktOut">| </span></p></td></tr><tr><td><p><span class="RktOut">-----------</span></p></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr></table></blockquote></td></tr></table></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:property</span><span class="hspace">&nbsp;</span><span class="RktVar">prop-expr</span><span class="hspace">&nbsp;</span><span class="RktVar">val-expr</span></td></tr></table></blockquote><p>Associates a <a name="(tech._property)"></a><span style="font-style: italic">property</span> and value with the structure type.
  For example, the <span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._prop%7E3aprocedure%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">prop:procedure</a></span> property allows a
  structure instance to be used as a function; the property value
  determines how a call is implemented when using the structure as a
  function.</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">greeter</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">name</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:property</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._prop%7E3aprocedure%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">prop:procedure</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">self</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=strings.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._string-append%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">string-append</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktVal">"Hi "</span><span class="hspace">&nbsp;</span><span class="RktSym">other</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktVal">", I'm "</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">greeter-name</span><span class="hspace">&nbsp;</span><span class="RktSym">self</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">joe-greet</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">greeter</span><span class="hspace">&nbsp;</span><span class="RktVal">"Joe"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td> </td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">greeter-name</span><span class="hspace">&nbsp;</span><span class="RktSym">joe-greet</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Joe"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">joe-greet</span><span class="hspace">&nbsp;</span><span class="RktVal">"Mary"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Hi Mary, I'm Joe"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">joe-greet</span><span class="hspace">&nbsp;</span><span class="RktVal">"John"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"Hi John, I'm Joe"</span></p></td></tr></table></blockquote></td></tr></table></blockquote></blockquote><blockquote class="leftindent"><blockquote class="leftindent"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><span class="RktPn">#:super</span><span class="hspace">&nbsp;</span><span class="RktVar">super-expr</span></td></tr></table></blockquote><p>An alternative to supplying a <span class="RktSym">super-id</span> next to
<span class="RktSym">struct-id</span>. Instead of the name of a structure type (which is
not an expression), <span class="RktVar">super-expr</span> should produce a
<a href="#%28tech._structure._type._descriptor%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type descriptor</span></a> value. An advantage of
<span class="RktPn">#:super</span> is that structure type descriptors are values, so
they can be passed to procedures.</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><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._define%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">raven-constructor</span><span class="hspace">&nbsp;</span><span class="RktSym">super-type</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=define-struct.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._struct%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">raven</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:super</span><span class="hspace">&nbsp;</span><span class="RktSym">super-type</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:transparent</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">#:property</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=procedures.html%23%2528def._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._prop%7E3aprocedure%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">prop:procedure</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=lambda.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fbase..rkt%2529._lambda%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">lambda</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">self</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktVal">'</span><span class="RktVal">nevermore</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">raven</span><span class="RktPn">)</span></td></tr><tr><td> </td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">r</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">raven-constructor</span><span class="hspace">&nbsp;</span><span class="RktSym">struct:posn</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">r</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">r</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">(list (raven 1 2) 'nevermore)</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=let.html%23%2528form._%2528%2528lib._racket%252Fprivate%252Fletstx-scheme..rkt%2529._let%2529%2529&amp;version=6.1" class="RktStxLink Sq" data-pltdoc="x">let</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">r</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">(</span><span class="RktSym">raven-constructor</span><span class="hspace">&nbsp;</span><span class="RktSym">struct:thing</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">"apple"</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=pairs.html%23%2528def._%2528%2528quote._%7E23%7E25kernel%2529._list%2529%2529&amp;version=6.1" class="RktValLink Sq" data-pltdoc="x">list</a></span><span class="hspace">&nbsp;</span><span class="RktSym">r</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">r</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">(list (raven "apple") 'nevermore)</span></p></td></tr></table></blockquote></td></tr></table></blockquote></blockquote><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="magnify.png" alt="+" width="24" height="24"/></span><a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=structures.html&amp;version=6.1" class="Sq" data-pltdoc="x">Structures</a> in <a href="http://download.racket-lang.org/docs/6.1/html/local-redirect/index.html?doc=reference&amp;rel=index.html&amp;version=6.1" class="Sq" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a> provides more on structure types.</p></blockquote></blockquote></blockquote><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.1&quot;, &quot;../&quot;);" onfocus="this.style.color=&quot;black&quot;; this.style.textAlign=&quot;left&quot;; if (this.value == &quot;...search manuals...&quot;) this.value=&quot;&quot;;" onblur="if (this.value.match(/^ *$/)) { this.style.color=&quot;#888&quot;; this.style.textAlign=&quot;center&quot;; this.value=&quot;...search manuals...&quot;; }"/></form>&nbsp;&nbsp;<a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;6.1&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="parameterize.html" title="backward to &quot;4.13 Dynamic Binding: parameterize&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="index.html" title="up to &quot;The Racket Guide&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="modules.html" title="forward to &quot;6 Modules&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>