This file is indexed.

/usr/share/doc/racket/reference/define-struct.html is in racket-doc 6.7-3.

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

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
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
<!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.1&nbsp;Defining Structure Types: struct</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="icons.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;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="structures.html" class="tocviewselflink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18&nbsp;</td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9660;</a></td><td>5&nbsp;</td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">5.1&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">Defining 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="creatingmorestructs.html" class="tocviewlink" data-pltdoc="x">Creating Structure Types</a></td></tr><tr><td align="right">5.3&nbsp;</td><td><a href="structprops.html" class="tocviewlink" data-pltdoc="x">Structure Type Properties</a></td></tr><tr><td align="right">5.4&nbsp;</td><td><a href="struct-generics.html" class="tocviewlink" data-pltdoc="x">Generic Interfaces</a></td></tr><tr><td align="right">5.5&nbsp;</td><td><a href="struct-copy.html" class="tocviewlink" data-pltdoc="x">Copying and Updating Structures</a></td></tr><tr><td align="right">5.6&nbsp;</td><td><a href="structutils.html" class="tocviewlink" data-pltdoc="x">Structure Utilities</a></td></tr><tr><td align="right">5.7&nbsp;</td><td><a href="structinfo.html" class="tocviewlink" data-pltdoc="x">Structure Type Transformer Binding</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">struct</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-field-index%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">struct-<wbr></wbr>field-<wbr></wbr>index</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define-<wbr></wbr>struct</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%2Fderived%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define-<wbr></wbr>struct/<span class="mywbr"> &nbsp;</span>derived</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.7&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.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="structures.html" title="backward to &quot;5 Structures&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="structures.html" title="up to &quot;5 Structures&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="creatingmorestructs.html" title="forward to &quot;5.2 Creating Structure Types&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h4 x-source-module="(lib &quot;scribblings/reference/reference.scrbl&quot;)" x-source-pkg="racket-doc" x-part-tag="&quot;define-struct&quot;">5.1<tt>&nbsp;</tt><a name="(part._define-struct)"></a>Defining Structure Types: <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span></h4><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p><span class="imageleft"><img src="finger.png" alt="+" width="24" height="24"/></span><a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=guide&amp;rel=define-struct.html&amp;version=6.7" class="Sq" data-pltdoc="x">Programmer-Defined Datatypes</a> in <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=guide&amp;rel=index.html&amp;version=6.7" class="Sq" data-pltdoc="x"><span style="font-weight: bold">The Racket Guide</span></a> introduces <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>.</p></blockquote></blockquote></blockquote><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><table cellspacing="0" cellpadding="0" class="RktBlk RForeground"><tr><td><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._struct))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">struct</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">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></blockquote></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><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">struct-option</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">#:mutable</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">#:super</span><span class="hspace">&nbsp;</span><span class="RktVar">super-expr</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">#:inspector</span><span class="hspace">&nbsp;</span><span class="RktVar">inspector-expr</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">#:auto-value</span><span class="hspace">&nbsp;</span><span class="RktVar">auto-expr</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">#:guard</span><span class="hspace">&nbsp;</span><span class="RktVar">guard-expr</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">#: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><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">#:transparent</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">#:prefab</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">#:name</span><span class="hspace">&nbsp;</span><span class="RktVar">name-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">#:extra-name</span><span class="hspace">&nbsp;</span><span class="RktVar">name-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">#:constructor-name</span><span class="hspace">&nbsp;</span><span class="RktVar">constructor-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">#:extra-constructor-name</span><span class="hspace">&nbsp;</span><span class="RktVar">constructor-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">#:reflection-name</span><span class="hspace">&nbsp;</span><span class="RktVar">symbol-expr</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">#:methods</span><span class="hspace">&nbsp;</span><span class="RktVar">gen:name</span><span class="hspace">&nbsp;</span><span class="RktVar">method-defs</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">#:omit-define-syntaxes</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">#:omit-define-values</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-option</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">#:mutable</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">#:auto</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">method-defs</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">definition</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="argcontract"><tr><td><span class="hspace">&nbsp;&nbsp;</span></td><td><span class="RktVar">gen:name</span></td><td><span class="hspace">&nbsp;</span></td><td>:</td><td><span class="hspace">&nbsp;</span></td><td><span class="RktSym"><a href="stxops.html#%28def._%28%28lib._racket%2Fprivate%2Fstx..rkt%29._identifier~3f%29%29" class="RktValLink" data-pltdoc="x">identifier?</a></span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Creates a new <a href="structures.html#%28tech._structure._type%29" data-pltdoc="x">structure type</a> (or uses a pre-existing
structure type if <span class="RktPn">#:prefab</span> is specified), and binds
transformers and variables related to the <a href="structures.html#%28tech._structure._type%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type</span></a>.</div></p><p>A <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> form with <span style="font-style: italic">n</span> <span class="RktVar">field</span>s defines up
to <span style="font-style: italic"></span>4<span style="font-style: italic">+</span>2<span style="font-style: italic">n</span> names:</p><ul><li><p><span class="RktSym">struct:</span><span class="RktVar">id</span>, a <a name="(tech._structure._type._descriptor)"></a><span style="font-style: italic">structure type
descriptor</span> value that represents the <a href="structures.html#%28tech._structure._type%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type</span></a>.</p></li><li><p><span class="RktVar">constructor-id</span> (which defaults to <span class="RktVar">id</span>), a
<a name="(tech._constructor)"></a><span style="font-style: italic">constructor</span> procedure that takes <span style="font-style: italic">m</span> arguments
and returns a new instance of the <a href="structures.html#%28tech._structure._type%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type</span></a>, where
<span style="font-style: italic">m</span> is the number of <span class="RktVar">field</span>s that do not include
an <span class="RktPn">#:auto</span> option.</p></li><li><p><span class="RktVar">name-id</span> (which defaults to <span class="RktVar">id</span>),
a <a href="syntax-model.html#%28tech._transformer%29" class="techoutside" data-pltdoc="x"><span class="techinside">transformer</span></a> binding that encapsulates
information about the structure type declaration. This binding
is used to define subtypes, and it also works with the
<span class="RktSym"><a href="shared.html#%28form._%28%28lib._racket%2Fshared..rkt%29._shared%29%29" class="RktStxLink" data-pltdoc="x">shared</a></span> and <span class="RktSym"><a href="match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span> forms. For detailed
information about the binding of <span class="RktVar">name-id</span>, see
<a href="structinfo.html" data-pltdoc="x">Structure Type Transformer Binding</a>.</p><p>The <span class="RktVar">constructor-id</span> and <span class="RktVar">name-id</span> can be the same, in
which case <span class="RktVar">name-id</span> performs both roles. In that case, the
expansion of <span class="RktVar">name-id</span> as an expression produces an otherwise
inaccessible identifier that is bound to the constructor
procedure; the expanded identifier has a
<span class="RktVal">'</span><span class="RktVal">constructor-for</span> property whose value is an identifier
that is <span class="RktSym"><a href="stxcmp.html#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29" class="RktValLink" data-pltdoc="x">free-identifier=?</a></span> to <span class="RktVar">name-id</span> as well as
a syntax property accessible via
<span class="RktSym">syntax-procedure-alias-property</span> with an identifier
that is <span class="RktSym"><a href="stxcmp.html#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29" class="RktValLink" data-pltdoc="x">free-identifier=?</a></span> to <span class="RktVar">name-id</span>.</p></li><li><p><span class="RktVar">id</span><span class="RktSym">?</span>, a <a name="(tech._predicate)"></a><span style="font-style: italic">predicate</span> procedure
that returns <span class="RktVal">#t</span> for instances of the <a href="structures.html#%28tech._structure._type%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure
type</span></a> (constructed by <span class="RktVar">constructor-id</span> or the
<a href="#%28tech._constructor%29" class="techoutside" data-pltdoc="x"><span class="techinside">constructor</span></a> for a subtype) and <span class="RktVal">#f</span> for any other
value.</p></li><li><p><span class="RktVar">id</span><span class="RktSym">-</span><span class="RktVar">field-id</span>, for each
<span class="RktVar">field</span>; an <a name="(tech._accessor)"></a><span style="font-style: italic">accessor</span> procedure that takes an
instance of the <a href="structures.html#%28tech._structure._type%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type</span></a> and extracts the value
for the corresponding field.</p></li><li><p><span class="RktSym">set-</span><span class="RktVar">id</span><span class="RktSym">-</span><span class="RktVar">field-id</span><span class="RktSym">!</span>,
for each <span class="RktVar">field</span> that includes a
<span class="RktPn">#:mutable</span> option, or when the
<span class="RktPn">#:mutable</span> option is specified as a
<span class="RktVar">struct-option</span>; a <a name="(tech._mutator)"></a><span style="font-style: italic">mutator</span> procedure that
takes an instance of the <a href="structures.html#%28tech._structure._type%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type</span></a> and a new field
value. The structure is destructively updated with the new
value, and <a href="https://download.racket-lang.org/docs/6.7/html/local-redirect/index.html?doc=guide&amp;rel=void_undefined.html&amp;version=6.7" class="RktModLink Sq" data-pltdoc="x"><span class="nobreak"><span class="RktRes">#&lt;void&gt;</span></span></a> is returned.</p></li></ul><p>If <span class="RktVar">super-id</span> is provided, it must have a transformer binding
of the same sort bound to <span class="RktVar">name-id</span> (see <a href="structinfo.html" data-pltdoc="x">Structure Type Transformer Binding</a>),
and it specifies a supertype for the structure type. Alternately,
the <span class="RktPn">#:super</span> option can be used to specify an expression that
must produce a <a href="#%28tech._structure._type._descriptor%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type descriptor</span></a>. See
<a href="structures.html" data-pltdoc="x">Structures</a> for more information on structure subtypes
and supertypes. If both <span class="RktVar">super-id</span> and <span class="RktPn">#:super</span> are
provided, a syntax error is reported.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">document</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">author</span><span class="hspace">&nbsp;</span><span class="RktSym">title</span><span class="hspace">&nbsp;</span><span class="RktSym">content</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">book</span><span class="hspace">&nbsp;</span><span class="RktSym">document</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">publisher</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">paper</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">journal</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:super</span><span class="hspace">&nbsp;</span><span class="RktSym">struct:document</span><span class="RktPn">)</span></td></tr></table></blockquote></div></p><p>If the <span class="RktPn">#:mutable</span> option is specified for an individual
field, then the field can be mutated in instances of the structure
type, and a <a href="#%28tech._mutator%29" class="techoutside" data-pltdoc="x"><span class="techinside">mutator</span></a> procedure is bound. Supplying
<span class="RktPn">#:mutable</span> as a <span class="RktVar">struct-option</span> is the same as
supplying it for all <span class="RktVar">field</span>s. If <span class="RktPn">#:mutable</span> is
specified as both a <span class="RktVar">field-option</span> and <span class="RktVar">struct-option</span>,
a syntax error is reported.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">cell</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">content</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">#:transparent</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">a-cell</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">cell</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">set-cell-content!</span><span class="hspace">&nbsp;</span><span class="RktSym">a-cell</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr></table></blockquote></div></p><p>The <span class="RktPn">#:inspector</span>, <span class="RktPn">#:auto-value</span>, and <span class="RktPn">#:guard</span>
options specify an inspector, value for automatic fields, and guard
procedure, respectively. See <span class="RktSym"><a href="creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._make-struct-type%29%29" class="RktValLink" data-pltdoc="x">make-struct-type</a></span> for more
information on these attributes of a structure type.  The
<span class="RktPn">#:property</span> option, which is the only one that can be supplied
multiple times, attaches a property value to the structure type; see
<a href="structprops.html" data-pltdoc="x">Structure Type Properties</a> for more information on properties. The
<span class="RktPn">#:transparent</span> option is a shorthand for <span class="RktPn">#:inspector</span><span class="stt"> </span><span class="RktVal">#f</span>.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">point</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">#:inspector</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">point</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(point 3 5)</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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">celsius</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">temp</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:guard</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="lambda.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._~ce~bb%29%29" class="RktStxLink" data-pltdoc="x">&#955;</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">temp</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;</span><span class="RktPn">(</span><span class="RktSym"><a href="when_unless.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._unless%29%29" class="RktStxLink" data-pltdoc="x">unless</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29" class="RktStxLink" data-pltdoc="x">and</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._real~3f%29%29" class="RktValLink" data-pltdoc="x">real?</a></span><span class="hspace">&nbsp;</span><span class="RktSym">temp</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._~3e~3d%29%29" class="RktValLink" data-pltdoc="x">&gt;=</a></span><span class="hspace">&nbsp;</span><span class="RktSym">temp</span><span class="hspace">&nbsp;</span><span class="RktVal"><span class="nobreak">-2</span>73.15</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;</span><span class="RktPn">(</span><span class="RktSym"><a href="exns.html#%28def._%28%28quote._~23~25kernel%29._error%29%29" class="RktValLink" data-pltdoc="x">error</a></span><span class="hspace">&nbsp;</span><span class="RktVal">"not a valid temperature"</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;</span><span class="RktSym">temp</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">celsius</span><span class="hspace">&nbsp;</span><span class="RktVal"><span class="nobreak">-2</span>75</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">not a valid temperature</span></p></td></tr></table></blockquote></div></p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>Use the <span class="RktSym"><a href="procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._prop~3aprocedure%29%29" class="RktValLink" data-pltdoc="x">prop:procedure</a></span> property to implement an
<a name="(idx._(gentag._169._(lib._scribblings/reference/reference..scrbl)))"></a>applicable structure, use <span class="RktSym"><a href="sync.html#%28def._%28%28quote._~23~25kernel%29._prop~3aevt%29%29" class="RktValLink" data-pltdoc="x">prop:evt</a></span> to create a
structure type whose instances are <a href="sync.html#%28tech._synchronizable._event%29" class="techoutside" data-pltdoc="x"><span class="techinside">synchronizable events</span></a>, and
so on. By convention, property names start with <span class="RktSym">prop:</span>.</p></blockquote></blockquote></blockquote><p>The <span class="RktPn">#:prefab</span> option obtains a <a href="structures.html#%28tech._prefab%29" data-pltdoc="x">prefab</a> (pre-defined,
globally shared) structure type, as opposed to creating a new
structure type. Such a structure type is inherently transparent and
cannot have a guard or properties, so using <span class="RktPn">#:prefab</span> with
<span class="RktPn">#:transparent</span>, <span class="RktPn">#:inspector</span>, <span class="RktPn">#:guard</span>, or
<span class="RktPn">#:property</span> is a syntax error. If a supertype is specified, it
must also be a <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> structure type.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">prefab-point</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">#:prefab</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">prefab-point</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">'#s(prefab-point 1 2)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">prefab-point?</span><span class="hspace">&nbsp;</span><span class="RktVal">#s</span><span class="RktVal">(</span><span class="RktVal">prefab-point</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#t</span></p></td></tr></table></blockquote></div></p><p>If <span class="RktVar">name-id</span> is supplied via <span class="RktPn">#:extra-name</span> and it is
not <span class="RktVar">id</span>, then both <span class="RktVar">name-id</span> and <span class="RktVar">id</span> are bound
to information about the structure type. Only one of
<span class="RktPn">#:extra-name</span> and <span class="RktPn">#:name</span> can be provided within a
<span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> form.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">ghost</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">color</span><span class="hspace">&nbsp;</span><span class="RktSym">name</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:prefab</span><span class="hspace">&nbsp;</span><span class="RktPn">#:extra-name</span><span class="hspace">&nbsp;</span><span class="RktSym">GHOST</span><span class="RktPn">)</span></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="match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">ghost</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">red</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">blinky</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="RktPn">(</span><span class="RktSym">GHOST</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="hspace">&nbsp;</span><span class="RktSym">n</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">c</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktRes">'red</span></p></td></tr></table></blockquote></div></p><p>If <span class="RktVar">constructor-id</span> is supplied, then the <a href="syntax-model.html#%28tech._transformer%29" class="techoutside" data-pltdoc="x"><span class="techinside">transformer</span></a>
binding of <span class="RktVar">name-id</span> records <span class="RktVar">constructor-id</span> as the
constructor binding; as a result, for example, <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-out%29%29" class="RktStxLink" data-pltdoc="x">struct-out</a></span>
includes <span class="RktVar">constructor-id</span> as an export. If
<span class="RktVar">constructor-id</span> is supplied via
<span class="RktPn">#:extra-constructor-name</span> and it is not <span class="RktVar">id</span>, applying
<span class="RktSym"><a href="inspectors.html#%28def._%28%28quote._~23~25kernel%29._object-name%29%29" class="RktValLink" data-pltdoc="x">object-name</a></span> on the constructor produces the symbolic form of
<span class="RktVar">id</span> rather than <span class="RktVar">constructor-id</span>. If
<span class="RktVar">constructor-id</span> is supplied via <span class="RktPn">#:constructor-name</span>
and it is not the same as <span class="RktVar">name-id</span>, then <span class="RktVar">name-id</span> does not serve
as a constructor, and <span class="RktSym"><a href="inspectors.html#%28def._%28%28quote._~23~25kernel%29._object-name%29%29" class="RktValLink" data-pltdoc="x">object-name</a></span> on the constructor produces
the symbolic form of <span class="RktVar">constructor-id</span>. Only one of
<span class="RktPn">#:extra-constructor-name</span> and <span class="RktPn">#:constructor-name</span>
can be provided within a <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> form.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">color</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">r</span><span class="hspace">&nbsp;</span><span class="RktSym">g</span><span class="hspace">&nbsp;</span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:constructor-name</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="nobreak">-c</span>olor</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">rectangle</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">w</span><span class="hspace">&nbsp;</span><span class="RktSym">h</span><span class="hspace">&nbsp;</span><span class="RktSym">color</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:extra-constructor-name</span><span class="hspace">&nbsp;</span><span class="RktSym">rect</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">rectangle</span><span class="hspace">&nbsp;</span><span class="RktVal">13</span><span class="hspace">&nbsp;</span><span class="RktVal">50</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="nobreak">-c</span>olor</span><span class="hspace">&nbsp;</span><span class="RktVal">192</span><span class="hspace">&nbsp;</span><span class="RktVal">157</span><span class="hspace">&nbsp;</span><span class="RktVal">235</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#&lt;rectangle&gt;</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">rect</span><span class="hspace">&nbsp;</span><span class="RktVal">50</span><span class="hspace">&nbsp;</span><span class="RktVal">37</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="nobreak">-c</span>olor</span><span class="hspace">&nbsp;</span><span class="RktVal">35</span><span class="hspace">&nbsp;</span><span class="RktVal">183</span><span class="hspace">&nbsp;</span><span class="RktVal">252</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#&lt;rectangle&gt;</span></p></td></tr></table></blockquote></div></p><p>If <span class="RktPn">#:reflection-name</span><span class="stt"> </span><span class="RktVar">symbol-expr</span> is provided, then
<span class="RktVar">symbol-expr</span> must produce a symbol that is used to identify
the structure type in reflective operations such as
<span class="RktSym"><a href="inspectors.html#%28def._%28%28quote._~23~25kernel%29._struct-type-info%29%29" class="RktValLink" data-pltdoc="x">struct-type-info</a></span>. It corresponds to the first argument of
<span class="RktSym"><a href="creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._make-struct-type%29%29" class="RktValLink" data-pltdoc="x">make-struct-type</a></span>. Structure printing uses the reflective
name, as do the various procedures that are bound by <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">circle</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">radius</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:reflection-name</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">&lt;circle&gt;</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">circle</span><span class="hspace">&nbsp;</span><span class="RktVal">15</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">#&lt;|&lt;circle&gt;|&gt;</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">circle-radius</span><span class="hspace">&nbsp;</span><span class="RktVal">"bad"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">&lt;circle&gt;-radius: contract violation</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: &lt;circle&gt;?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: "bad"</span></p></td></tr></table></blockquote></div></p><p>If <span class="RktPn">#:methods</span><span class="stt"> </span><span class="RktVar">gen:name</span><span class="stt"> </span><span class="RktVar">method-defs</span> is provided, then
<span class="RktVar">gen:name</span> must be a transformer binding for the static
information about a generic interface produced by <span class="RktSym"><a href="struct-generics.html#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define-generics%29%29" class="RktStxLink" data-pltdoc="x">define-generics</a></span>.
The <span class="RktVar">method-defs</span> define the methods of the <span class="RktVar">gen:name</span>
interface. A <span class="RktSym"><a href="struct-generics.html#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29" class="RktStxLink" data-pltdoc="x">define/generic</a></span> form or auxiliary definitions
and expressions may also appear in <span class="RktVar">method-defs</span>.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">constant-stream</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">val</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:methods</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="streams.html#%28def._%28%28lib._racket%2Fstream..rkt%29._gen~3astream%29%29" class="RktValLink" data-pltdoc="x">gen:stream</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="streams.html#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-empty~3f%29%29" class="RktValLink" data-pltdoc="x">stream-empty?</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="streams.html#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="streams.html#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-first%29%29" class="RktValLink" data-pltdoc="x">stream-first</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="streams.html#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym">constant-stream-val</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="streams.html#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></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;</span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="streams.html#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-rest%29%29" class="RktValLink" data-pltdoc="x">stream-rest</a></span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="streams.html#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="streams.html#%28form._%28%28lib._racket%2Fstream..rkt%29._stream%29%29" class="RktStxLink" data-pltdoc="x">stream</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="streams.html#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29" class="RktValLink" data-pltdoc="x">stream-ref</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">constant-stream</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">forever</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'forever</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="streams.html#%28def._%28%28lib._racket%2Fstream..rkt%29._stream-ref%29%29" class="RktValLink" data-pltdoc="x">stream-ref</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">constant-stream</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">forever</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktVal">50</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'forever</span></p></td></tr></table></blockquote></div></p><p>If the <span class="RktPn">#:omit-define-syntaxes</span> option is supplied, then
<span class="RktVar">name-id</span> (and <span class="RktVar">id</span>, if <span class="RktPn">#:extra-name</span> is specified])
is not bound as a transformer. If the
<span class="RktPn">#:omit-define-values</span> option is supplied, then none of the
usual variables are bound, but <span class="RktVar">id</span> is bound. If both are
supplied, then the <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> form is equivalent to
<span class="RktPn">(</span><span class="RktSym"><a href="begin.html#%28form._%28%28quote._~23~25kernel%29._begin%29%29" class="RktStxLink" data-pltdoc="x">begin</a></span><span class="RktPn">)</span>.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">side</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:omit-define-syntaxes</span><span class="RktPn">)</span></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="match.html#%28form._%28%28lib._racket%2Fmatch..rkt%29._match%29%29" class="RktStxLink" data-pltdoc="x">match</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktVal">5</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">fails to match because syntax is omitted</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">square</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p><span class="RktErr">eval:28:0: match: square does not refer to a structure</span></p></td></tr><tr><td><p><span class="RktErr">definition</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">at: square</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: (struct square x)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">ellipse</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">#:omit-define-values</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">ellipse-width</span></td></tr><tr><td><p><span class="RktErr">ellipse-width: 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></div></p><p><div class="SIntrapara"><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>Expressions supplied to <span class="RktPn">#:auto-value</span> are evaluated once and shared
between every instance of the structure type. In particular, updates to
a mutable <span class="RktPn">#:auto-value</span> affect all current and future instances.</p></blockquote></blockquote></blockquote></div><div class="SIntrapara">If <span class="RktPn">#:auto</span> is supplied as a <span class="RktVar">field-option</span>, then the
<a href="#%28tech._constructor%29" class="techoutside" data-pltdoc="x"><span class="techinside">constructor</span></a> procedure for the structure type does not accept an
argument corresponding to the field. Instead, the structure type&rsquo;s
automatic value is used for the field, as specified by the
<span class="RktPn">#:auto-value</span> option, or as defaults to <span class="RktVal">#f</span> when
<span class="RktPn">#:auto-value</span> is not supplied. The field is mutable (e.g.,
through reflective operations), but a mutator procedure is bound only
if <span class="RktPn">#:mutable</span> is specified.</div></p><p>If a <span class="RktVar">field</span> includes the <span class="RktPn">#:auto</span> option, then all
fields after it must also include <span class="RktPn">#:auto</span>, otherwise a syntax
error is reported. If any <span class="RktVar">field-option</span> or
<span class="RktVar">struct-option</span> keyword is repeated, other than
<span class="RktPn">#:property</span>, a syntax error is reported.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" 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="hspace">&nbsp;</span><span class="RktPn">#:mutable</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:auto-value</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span></td></tr><tr><td><span class="hspace">&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><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><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><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><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">posn-z</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">0</span></p></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">color-posn</span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">hue</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">#:mutable</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">cp</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">color-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">"blue"</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">color-posn-hue</span><span class="hspace">&nbsp;</span><span class="RktSym">cp</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">"blue"</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktSym">cp</span></td></tr><tr><td><p><span class="RktRes">(color-posn 1 2 0 ...)</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">set-posn-z!</span><span class="hspace">&nbsp;</span><span class="RktSym">cp</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr></table></blockquote></div></p><p>For serialization, see <span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._define-serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">define-serializable-struct</a></span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._struct-field-index))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-field-index%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">struct-field-index</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">field-id</span><span class="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">This form can only appear as an expression within a
<span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> form; normally, it is used with
<span class="RktPn">#:property</span>, especially for a property like
<span class="RktSym"><a href="procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._prop~3aprocedure%29%29" class="RktValLink" data-pltdoc="x">prop:procedure</a></span>. The result of a <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-field-index%29%29" class="RktStxLink" data-pltdoc="x">struct-field-index</a></span>
expression is an exact, non-negative integer that corresponds to the
position within the structure declaration of the field named by
<span class="RktVar">field-id</span>.</div></p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace">&nbsp;</span><span class="RktSym">mood-procedure</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">base</span><span class="hspace">&nbsp;</span><span class="RktSym">rating</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">#:property</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._prop~3aprocedure%29%29" class="RktValLink" data-pltdoc="x">prop:procedure</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct-field-index%29%29" class="RktStxLink" data-pltdoc="x">struct-field-index</a></span><span class="hspace">&nbsp;</span><span class="RktSym">base</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace">&nbsp;</span><span class="RktSym">happy+</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">mood-procedure</span><span class="hspace">&nbsp;</span><span class="RktSym"><a href="generic-numbers.html#%28def._%28%28quote._~23~25kernel%29._add1%29%29" class="RktValLink" data-pltdoc="x">add1</a></span><span class="hspace">&nbsp;</span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><p>&nbsp;</p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">happy+</span><span class="hspace">&nbsp;</span><span class="RktVal">2</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">mood-procedure-rating</span><span class="hspace">&nbsp;</span><span class="RktSym">happy+</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">10</span></p></td></tr></table></blockquote></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><table cellspacing="0" cellpadding="0" class="RktBlk RForeground"><tr><td><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._define-struct))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-struct</a></span></span><span class="hspace">&nbsp;</span><span class="RktVar">id-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;&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></blockquote></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">id-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"><span class="RktVar">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">id</span><span class="hspace">&nbsp;</span><span class="RktVar">super-id</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>, except that the syntax for supplying a
<span class="RktVar">super-id</span> is different, and a <span class="RktVar">constructor-id</span> that
has a <span class="RktSym">make-</span> prefix on <span class="RktVar">id</span> is implicitly
supplied via <span class="RktPn">#:extra-constructor-name</span> if neither
<span class="RktPn">#:extra-constructor-name</span> nor <span class="RktPn">#:constructor-name</span> is
provided.</div></p><p>This form is provided for backwards compatibility; <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> is
preferred.</p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-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;&nbsp;</span><span class="RktPn">#:auto-value</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span></td></tr><tr><td><span class="hspace">&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><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">make-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><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">make-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><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">make-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></div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><table cellspacing="0" cellpadding="0" class="RktBlk RForeground"><tr><td><span class="RktPn">(</span><a name="(form._((lib._racket/private/base..rkt)._define-struct/derived))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%2Fderived%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-struct/derived</a></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktVar">id</span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktVar">rest-form</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">id-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><span class="hspace">&nbsp;</span><span class="RktVar">struct-option</span><span class="hspace">&nbsp;</span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">The same as <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span>, but with an extra <span class="RktPn">(</span><span class="RktVar">id</span><span class="stt"> </span><span class="RktPn">. </span><span class="RktVar">rest-form</span><span class="RktPn">)</span> sub-form that is treated as the overall form for
syntax-error reporting and otherwise ignored.  The only constraint on
the sub-form for error reporting is that it starts with <span class="RktVar">id</span>.
The <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%2Fderived%29%29" class="RktStxLink" data-pltdoc="x">define-struct/derived</a></span> form is intended for use by macros
that expand to <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span>.</div></p><p><div class="SIntrapara">Examples:</div><div class="SIntrapara"><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="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-syntax%29%29" class="RktStxLink" data-pltdoc="x">define-syntax</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">define-xy-struct</span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._syntax-case%29%29" class="RktStxLink" data-pltdoc="x">syntax-case</a></span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="hspace">&nbsp;</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="RktPn">(</span><span class="RktSym">ds</span><span class="hspace">&nbsp;</span><span class="RktSym">name</span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><a href="pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._rest%29%29" class="RktValLink" data-pltdoc="x">rest</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._with-syntax%29%29" class="RktStxLink" data-pltdoc="x">with-syntax</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym">orig</span><span class="hspace">&nbsp;</span><span class="RktSym">stx</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktRdr">#'</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%2Fderived%29%29" class="RktStxLink" data-pltdoc="x">define-struct/derived</a></span><span class="hspace">&nbsp;</span><span class="RktSym">orig</span><span class="hspace">&nbsp;</span><span class="RktSym">name</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">. </span><span class="RktSym"><a href="pairs.html#%28def._%28%28lib._racket%2Flist..rkt%29._rest%29%29" class="RktValLink" data-pltdoc="x">rest</a></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><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">define-xy-struct</span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="RktPn">)</span></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="RktPn">(</span><span class="RktSym">make-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">define-xy-struct</span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">#:mutable</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">set-posn-x!</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-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="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">this next line will cause an error due to a bad keyword</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">define-xy-struct</span><span class="hspace">&nbsp;</span><span class="RktSym">posn</span><span class="hspace">&nbsp;</span><span class="RktPn">#:bad-option</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">eval:54:0: define-xy-struct: unrecognized</span></p></td></tr><tr><td><p><span class="RktErr">struct-specification keyword</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">at: #:bad-option</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: (define-xy-struct posn #:bad-option)</span></p></td></tr></table></blockquote></div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;6.7&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.7&quot;);">top</a></span><span class="navright">&nbsp;&nbsp;<a href="structures.html" title="backward to &quot;5 Structures&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="structures.html" title="up to &quot;5 Structures&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="creatingmorestructs.html" title="forward to &quot;5.2 Creating Structure Types&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>