emacs.d/clones/lisp/docs.racket-lang.org/reference/creatingmorestructs.html

88 lines
69 KiB
HTML
Raw Normal View History

2022-08-24 19:36:32 +02:00
<!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"/><meta name="viewport" content="width=device-width, initial-scale=0.8"/><title>5.2&nbsp;Creating Structure Types</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="../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">The Racket Reference</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"
<span class="RktVal">'</span><span class="RktVal">prefab</span>, in which case <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> accesses a
<a href="structures.html#%28tech._prefab%29" data-pltdoc="x">prefab</a> structure type. The <span class="RktVar">name</span> argument is used
as the type name. If <span class="RktVar">super-type</span> is not <span class="RktVal">#f</span>, the
resulting type is a subtype of the corresponding structure type.</div></p><p>The resulting structure type has
<span class="RktVar">init-field-cnt</span><span style="font-style: italic">+</span><span class="RktVar">auto-field-cnt</span> fields (in
addition to any fields from <span class="RktVar">super-type</span>), but only
<span class="RktVar">init-field-cnt</span> constructor arguments (in addition to any
constructor arguments from <span class="RktVar">super-type</span>). The remaining fields
are initialized with <span class="RktVar">auto-v</span>. The total field count (including
<span class="RktVar">super-type</span> fields) must be no more than 32768.</p><p>The <span class="RktVar">props</span> argument is a list of pairs, where the <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span>
of each pair is a structure type property descriptor, and the
<span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cdr%29%29" class="RktValLink" data-pltdoc="x">cdr</a></span> is an arbitrary value. A property can be specified
multiple times in <span class="RktVar">props</span> (including properties that are
automatically added by properties that are directly included in
<span class="RktVar">props</span>) only if the associated values are <span class="RktSym"><a href="Equality.html#%28def._%28%28quote._~23~25kernel%29._eq~3f%29%29" class="RktValLink" data-pltdoc="x">eq?</a></span>,
otherwise the <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29" class="RktValLink" data-pltdoc="x">exn:fail:contract</a></span> exception is raised. See <a href="structprops.html" data-pltdoc="x">Structure Type Properties</a>
for more information about properties. When <span class="RktVar">inspector</span> is
<span class="RktVal">'</span><span class="RktVal">prefab</span>, then <span class="RktVar">props</span> must be <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._null%29%29" class="RktValLink" data-pltdoc="x">null</a></span>.</p><p>The <span class="RktVar">inspector</span> argument normally controls access to reflective
information about the structure type and its instances; see
<a href="inspectors.html" data-pltdoc="x">Structure Inspectors</a> for more information. If <span class="RktVar">inspector</span> is
<span class="RktVal">'</span><span class="RktVal">prefab</span>, then the resulting <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> structure type and
its instances are always transparent. If <span class="RktVar">inspector</span> is
<span class="RktVal">#f</span>, then the structure type&rsquo;s instances are transparent.</p><p>If <span class="RktVar">proc-spec</span> is an integer or procedure, instances of the
structure type act as procedures. See <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> for
further information. Providing a non-<span class="RktVal">#f</span> value for
<span class="RktVar">proc-spec</span> is the same as pairing the value with
<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> at the end of <span class="RktVar">props</span>, plus including
<span class="RktVar">proc-spec</span> in <span class="RktVar">immutables</span> when <span class="RktVar">proc-spec</span> is
an integer.</p><p>The <span class="RktVar">immutables</span> argument provides a list of field
positions. Each element in the list must be unique, otherwise
<span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29" class="RktValLink" data-pltdoc="x">exn:fail:contract</a></span> exception is raised. Each element must also fall in the range
<span class="RktVal">0</span> (inclusive) to <span class="RktVar">init-field-cnt</span> (exclusive), otherwise
<span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail~3acontract%29%29" class="RktValLink" data-pltdoc="x">exn:fail:contract</a></span> exception is raised.</p><p>The <span class="RktVar">guard</span> argument is either a procedure of <span style="font-style: italic">n+</span>1<span style="font-style: italic"></span>
arguments or <span class="RktVal">#f</span>, where <span style="font-style: italic">n</span> is the number of arguments
for the new structure type&rsquo;s constructor (i.e.,
<span class="RktVar">init-field-cnt</span> plus constructor arguments implied by
<span class="RktVar">super-type</span>, if any). If <span class="RktVar">guard</span> is a procedure, then
the procedure is called whenever an instance of the type is
constructed, or whenever an instance of a subtype is created. The
arguments to <span class="RktVar">guard</span> are the values provided for the
structure&rsquo;s first <span style="font-style: italic">n</span> fields, followed by the name of the
instantiated structure type (which is <span class="RktVar">name</span>, unless a subtype
is instantiated). The <span class="RktVar">guard</span> result must be <span style="font-style: italic">n</span> values,
which become the actual values for the structure&rsquo;s fields. The
<span class="RktVar">guard</span> can raise an exception to prevent creation of a
structure with the given field values. If a structure subtype has its
own guard, the subtype guard is applied first, and the first <span style="font-style: italic">n</span>
values produced by the subtype&rsquo;s guard procedure become the first
<span style="font-style: italic">n</span> arguments to <span class="RktVar">guard</span>. When <span class="RktVar">inspector</span> is
<span class="RktVal">'</span><span class="RktVal">prefab</span>, then <span class="RktVar">guard</span> must be <span class="RktVal">#f</span>.</p><p>If <span class="RktVar">constructor-name</span> is not <span class="RktVal">#f</span>, it is used as the
name of the generated <a href="define-struct.html#%28tech._constructor%29" class="techoutside" data-pltdoc="x"><span class="techinside">constructor</span></a> procedure as returned by
<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> or in the printed form of the constructor value.</p><p>The result 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> is five values:</p><ul><li><p>a <a href="define-struct.html#%28tech._structure._type._descriptor%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type descriptor</span></a>,</p></li><li><p>a <a href="define-struct.html#%28tech._constructor%29" class="techoutside" data-pltdoc="x"><span class="techinside">constructor</span></a> procedure,</p></li><li><p>a <a href="define-struct.html#%28tech._predicate%29" class="techoutside" data-pltdoc="x"><span class="techinside">predicate</span></a> procedure,</p></li><li><p>an <a href="define-struct.html#%28tech._accessor%29" class="techoutside" data-pltdoc="x"><span class="techinside">accessor</span></a> procedure, which consumes a structure and a field
index between <span style="font-style: italic"></span>0<span style="font-style: italic"></span> (inclusive) and
<span class="RktVar">init-field-cnt</span><span style="font-style: italic">+</span><span class="RktVar">auto-field-cnt</span> (exclusive),
and</p></li><li><p>a <a href="define-struct.html#%28tech._mutator%29" class="techoutside" data-pltdoc="x"><span class="techinside">mutator</span></a> procedure, which consumes a structure, a field
index, and a field value.</p></li></ul><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%28quote._~23~25kernel%29._define-values%29%29" class="RktStxLink" data-pltdoc="x">define-values</a></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">struct:a</span><span class="hspace">&nbsp;</span><span class="RktSym">make-a</span><span class="hspace">&nbsp;</span><span class="RktSym">a?</span><span class="hspace">&nbsp;</span><span class="RktSym">a-ref</span><span class="hspace">&nbsp;</span><span class="RktSym">a-set!</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><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><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">a</span><span class="hspace">&nbsp;</span><span class="RktVal">#f</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">uninitialized</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">an-a</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">make-a</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">x</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">y</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">a-ref</span><span class="hspace">&nbsp;</span><span class="RktSym">an-a</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'y</span></p></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">a-ref</span><span class="hspace">&nbsp;</span><span class="RktSym">an-a</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'uninitialized</span></p></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-first</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><a href="creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._make-struct-field-accessor%29%29" class="RktValLink" data-pltdoc="x">make-struct-field-accessor</a></span><span class="hspace">&nbsp;</span><span class="RktSym">a-ref</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">a-first</span><span class="hspace">&nbsp;</span><span class="RktSym">an-a</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">'x</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="define.html#%28form._%28%28quote._~23~25kernel%29._de
an <a href="define-struct.html#%28tech._accessor%29" class="techoutside" data-pltdoc="x"><span class="techinside">accessor</span></a> returned by <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>.</div></p><p>The <span class="RktVar">field/proc-name</span> argument determines the name of the
resulting procedure for error reporting and debugging purposes. If
<span class="RktVar">field/proc-name</span> is a symbol and <span class="RktVar">arg-contract-str</span> is not
<span class="RktVal">#f</span>, then <span class="RktVar">field/proc-name</span> is used as the procedure
name. If <span class="RktVar">field/proc-name</span> is a symbol and
<span class="RktVar">arg-contract-str</span> is <span class="RktVal">#f</span>, then <span class="RktVar">field/proc-name</span> is
combined with the name of <span class="RktVar">accessor-proc</span>&rsquo;s structure type to
form the procedure name. If <span class="RktVar">field/proc-name</span> is <span class="RktVal">#f</span>,
then <span class="RktVal">'</span><span class="RktVal">accessor</span> is used as the procedure name.</p><p>The <span class="RktVar">arg-contract-str</span> argument determines how the accessor
procedure reports an error when it is applied to a value that is not
an instance of the <span class="RktVar">accessor-proc</span>&rsquo;s structure type. If it is a
string or symbol, the text of the string or symbol is used as a
contract for error reporting. Otherwise, contract text is synthesized
from the name of <span class="RktVar">accessor-proc</span>&rsquo;s structure type.</p><p>The <span class="RktVar">realm</span> argument is also used for error reporting. It
specifies a <a href="exns.html#%28tech._realm%29" class="techoutside" data-pltdoc="x"><span class="techinside">realm</span></a> that an error-message adjuster may use to
determine how to adjust an error message. The <span class="RktVar">realm</span> argument
also determines the result of <span class="RktSym"><a href="procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._procedure-realm%29%29" class="RktValLink" data-pltdoc="x">procedure-realm</a></span> for the
accessor procedure.</p><p>For examples, 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>.</p><p class="SHistory">Changed in version 8.4.0.2 of package <span class="stt">base</span>: Added the <span class="RktVar">arg-contract-str</span>
and <span class="RktVar">realm</span> arguments.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td valign="top"><span class="RktPn">(</span><a name="(def._((quote._~23~25kernel)._make-struct-field-mutator))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._make-struct-field-mutator%29%29" class="RktValDef RktValLink" data-pltdoc="x">make-struct-field-mutator</a></span></span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="RktVar">mutator-proc</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td></tr><tr><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="RktVar">field-pos</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td></tr><tr><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span><span class="RktOpt">[</span></td><td valign="top"><span class="RktVar">field/proc-name</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td></tr><tr><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="RktVar">arg-contract-str</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td></tr><tr><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="RktVar">realm</span><span class="RktOpt">]</span><span class="RktPn">)</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top">&rarr;</td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="RktSym"><a href="procedures.html#%28def._%28%28quote._~23~25kernel%29._procedure~3f%29%29" class="RktValLink" data-pltdoc="x">procedure?</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">mutator-proc</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="structutils.html#%28def._%28%28quote._~23~25kernel%29._struct-mutator-procedure~3f%29%29" class="RktValLink" data-pltdoc="x">struct-mutator-procedure?</a></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktVar">field-pos</span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td valign="top"><span class="hspace">&nbsp;&nbsp;</span></td><td valign="top"><span class="RktVar">field/proc-name</span></td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top">:</td><td valign="top"><span class="hspace">&nbsp;</span></td><td valign="top"><span class="RktPn">(</span><span class="RktSym"><a href=
a <a href="define-struct.html#%28tech._mutator%29" class="techoutside" data-pltdoc="x"><span class="techinside">mutator</span></a> returned by <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>.</div></p><p>The <span class="RktSym">field-name</span>, <span class="RktVar">arg-contract-str</span>, and <span class="RktVar">realm</span>
arguments are used for error and debugging purposes analogous to the
same arguments to <span class="RktSym"><a href="creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._make-struct-field-accessor%29%29" class="RktValLink" data-pltdoc="x">make-struct-field-accessor</a></span>.</p><p>For examples, 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>.</p><p class="SHistory">Changed in version 8.4.0.2 of package <span class="stt">base</span>: Added the <span class="RktVar">arg-contract-str</span>
and <span class="RktVar">realm</span> arguments.</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>value</p></div></div><p class="RForeground"><a name="(def._((quote._~23~25kernel)._prop~3asealed))"></a><span title="Provided from: racket/base, racket | Package: base"><span class="RktSym"><a href="creatingmorestructs.html#%28def._%28%28quote._~23~25kernel%29._prop~3asealed%29%29" class="RktValDef RktValLink" data-pltdoc="x">prop:sealed</a></span></span><span class="hspace">&nbsp;</span>:<span class="hspace">&nbsp;</span><span class="RktSym"><a href="structprops.html#%28def._%28%28quote._~23~25kernel%29._struct-type-property~3f%29%29" class="RktValLink" data-pltdoc="x">struct-type-property?</a></span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">A <a href="structprops.html#%28tech._structure._type._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type property</span></a> that declares a structure type as
<a name="(tech._sealed)"></a><span style="font-style: italic">sealed</span>. The value associated with the property is ignored;
the presence of the property itself makes the structure type
sealed.</div></p><p>A <a href="creatingmorestructs.html#%28tech._sealed%29" class="techoutside" data-pltdoc="x"><span class="techinside">sealed</span></a> structure type cannot be used as the supertype of
another structure type. Declaring a structure type as <a href="creatingmorestructs.html#%28tech._sealed%29" class="techoutside" data-pltdoc="x"><span class="techinside">sealed</span></a> is
typically just a performance hint, since checking for an instance of a
sealed structure type can be slightly faster than checking for an
instance of a structure type that might have subtypes.</p><p class="SHistory">Added in version 8.0.0.7 of package <span class="stt">base</span>.</p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" id="searchbox" type="text" tabindex="1" placeholder="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, &quot;8.6&quot;, &quot;../&quot;);"/></form>&nbsp;&nbsp;<a href="https://docs.racket-lang.org/index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot(&quot;8.6&quot;);">top</a><span class="tocsettoggle">&nbsp;&nbsp;<a href="javascript:void(0);" title="show/hide table of contents" onclick="TocsetToggle();">contents</a></span></span><span class="navright">&nbsp;&nbsp;<a href="define-struct.html" title="backward to &quot;5.1 Defining Structure Types: struct&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="structprops.html" title="forward to &quot;5.3 Structure Type Properties&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>