283 lines
128 KiB
HTML
283 lines
128 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
|
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=0.8"/><title>13.9 Serialization</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,"tocview_0");">►</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 </td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2 </td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3 </td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4 </td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5 </td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6 </td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7 </td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8 </td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9 </td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10 </td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11 </td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12 </td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13 </td><td><a href="input-and-output.html" class="tocviewselflink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14 </td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15 </td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16 </td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17 </td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18 </td><td><a href="running.html" class="toc
|
||
|
checking the content of compound values, and <span class="RktVal">#f</span> otherwise.
|
||
|
See <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span> for an enumeration of serializable values.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td valign="top" colspan="3"><span class="RktPn">(</span><a name="(def._((lib._racket/private/serialize..rkt)._serialize))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValDef RktValLink" data-pltdoc="x">serialize</a></span></span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">v</span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span><span class="RktOpt">[</span></td><td valign="top"><span class="RktPn">#:relative-directory</span><span class="hspace"> </span><span class="RktVar">relative-to</span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktPn">#:deserialize-relative-directory</span><span class="hspace"> </span><span class="RktVar">deserialize-relative-to</span><span class="RktOpt">]</span><span class="RktPn">)</span></td><td valign="top"><span class="hspace"> </span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serializable~3f%29%29" class="RktValLink" data-pltdoc="x">serializable?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">relative-to</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top">:</td><td valign="top"><span class="hspace"> </span></td><td valign="top"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._and%2Fc%29%29" class="RktValLink" data-pltdoc="x">and/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._path~3f%29%29" class="RktValLink" data-pltdoc="x">path?</a></span><span class="hspace"> </span><span class="RktSym"><a href="Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._complete-path~3f%29%29" class="RktValLink" data-pltdoc="x">complete-path?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.ht
|
||
|
includes only readable values, so it can be written to a stream with
|
||
|
<span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._write%29%29" class="RktValLink" data-pltdoc="x">write</a></span> or <span class="RktSym"><a href="fasl.html#%28def._%28%28lib._racket%2Ffasl..rkt%29._s-exp-~3efasl%29%29" class="RktValLink" data-pltdoc="x">s-exp->fasl</a></span>, later read from a stream using
|
||
|
<span class="RktSym"><a href="Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29" class="RktValLink" data-pltdoc="x">read</a></span> or <span class="RktSym"><a href="fasl.html#%28def._%28%28lib._racket%2Ffasl..rkt%29._fasl-~3es-exp%29%29" class="RktValLink" data-pltdoc="x">fasl->s-exp</a></span>, and then converted to a value
|
||
|
like the original using <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span>. Serialization followed
|
||
|
by deserialization produces a value with the same graph structure and
|
||
|
mutability as the original value, but the serialized value is a plain
|
||
|
tree (i.e., no sharing).</div></p><p>The following kinds of values are serializable:</p><ul><li><p>structures created through <span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span> or
|
||
|
<span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%2Fversions%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct/versions</a></span>, or more generally
|
||
|
structures with the <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29" class="RktValLink" data-pltdoc="x">prop:serializable</a></span> property (see
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29" class="RktValLink" data-pltdoc="x">prop:serializable</a></span> for more information);</p></li><li><p><a href="structures.html#%28tech._prefab%29" data-pltdoc="x">prefab</a> structures;</p></li><li><p>instances of classes defined with <span class="RktSym"><a href="objectserialize.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._define-serializable-class%29%29" class="RktStxLink" data-pltdoc="x">define-serializable-class</a></span>
|
||
|
or <span class="RktSym"><a href="objectserialize.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._define-serializable-class%2A%29%29" class="RktStxLink" data-pltdoc="x">define-serializable-class*</a></span>;</p></li><li><p><a href="booleans.html#%28tech._boolean%29" class="techoutside" data-pltdoc="x"><span class="techinside">booleans</span></a>, <a href="numbers.html#%28tech._number%29" class="techoutside" data-pltdoc="x"><span class="techinside">numbers</span></a>, <a href="characters.html#%28tech._character%29" class="techoutside" data-pltdoc="x"><span class="techinside">characters</span></a>, <a href="reader.html#%28tech._interned%29" class="techoutside" data-pltdoc="x"><span class="techinside">interned</span></a> symbols,
|
||
|
<a href="symbols.html#%28tech._unreadable._symbol%29" class="techoutside" data-pltdoc="x"><span class="techinside">unreadable symbols</span></a>, <a href="keywords.html#%28tech._keyword%29" class="techoutside" data-pltdoc="x"><span class="techinside">keywords</span></a>, <a href="strings.html#%28tech._string%29" class="techoutside" data-pltdoc="x"><span class="techinside">strings</span></a>, <a href="bytestrings.html#%28tech._byte._string%29" class="techoutside" data-pltdoc="x"><span class="techinside">byte strings</span></a>, <a href="pathutils.html#%28tech._path%29" class="techoutside" data-pltdoc="x"><span class="techinside">paths</span></a> (for a
|
||
|
specific convention), <a href="regexp.html#%28tech._regexp._value%29" class="techoutside" data-pltdoc="x"><span class="techinside">regexp values</span></a>, <a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=guide&rel=void_undefined.html&version=8.6" class="RktModLink Sq" data-pltdoc="x"><span class="nobreak"><span class="RktRes">#<void></span></span></a>, and the empty list;</p></li><li><p><a href="pairs.html#%28tech._pair%29" class="techoutside" data-pltdoc="x"><span class="techinside">pairs</span></a>, <a href="mpairs.html#%28tech._mutable._pair%29" class="techoutside" data-pltdoc="x"><span class="techinside">mutable pairs</span></a>, <a href="vectors.html#%28tech._vector%29" class="techoutside" data-pltdoc="x"><span class="techinside">vectors</span></a>, <a href="flonums.html#%28tech._flvector%29" class="techoutside" data-pltdoc="x"><span class="techinside">flvectors</span></a>, <a href="fixnums.html#%28tech._fxvector%29" class="techoutside" data-pltdoc="x"><span class="techinside">fxvectors</span></a>,
|
||
|
<a href="boxes.html#%28tech._box%29" class="techoutside" data-pltdoc="x"><span class="techinside">box</span></a>es, <a href="hashtables.html#%28tech._hash._table%29" class="techoutside" data-pltdoc="x"><span class="techinside">hash tables</span></a>, and <a href="sets.html#%28tech._set%29" class="techoutside" data-pltdoc="x"><span class="techinside">sets</span></a>;</p></li><li><p><span class="RktSym"><a href="time.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._date%29%29" class="RktValLink" data-pltdoc="x">date</a></span>, <span class="RktSym"><a href="time.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._date%2A%29%29" class="RktValLink" data-pltdoc="x">date*</a></span>, <span class="RktSym"><a href="procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._arity-at-least%29%29" class="RktValLink" data-pltdoc="x">arity-at-least</a></span> and <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._srcloc%29%29" class="RktValLink" data-pltdoc="x">srcloc</a></span>
|
||
|
structures; and</p></li><li><p><a href="Module_Names_and_Loading.html#%28tech._module._path._index%29" class="techoutside" data-pltdoc="x"><span class="techinside">module path index</span></a> values.</p></li></ul><p>Serialization succeeds for a compound value, such as a pair, only if
|
||
|
all content of the value is serializable. If a value given to
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span> is not completely serializable, 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.</p><p>If <span class="RktVar">v</span> contains a cycle (i.e., a collection of objects that
|
||
|
are all reachable from each other), then <span class="RktVar">v</span> can be serialized
|
||
|
only if the cycle includes a mutable value, where a <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a>
|
||
|
structure counts as mutable only if all of its fields are mutable.</p><p>If <span class="RktVar">relative-to</span> is not <span class="RktVal">#f</span>, then paths to serialize
|
||
|
that extend the path in <span class="RktVar">relative-to</span> are recorded in relative
|
||
|
and platform-independent form. The possible values and treatment of
|
||
|
<span class="RktVar">relative-to</span> are the same as for <span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._current-write-relative-directory%29%29" class="RktValLink" data-pltdoc="x">current-write-relative-directory</a></span>.</p><p>If <span class="RktVar">deserialize-relative-to</span> is not <span class="RktVal">#f</span>, then any paths
|
||
|
to deserializers as extracted via <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29" class="RktValLink" data-pltdoc="x">prop:serializable</a></span> are
|
||
|
recorded in relative form. Note that <span class="RktVar">relative-to</span> and
|
||
|
<span class="RktVar">deserialize-relative-to</span> are independent, but
|
||
|
<span class="RktVar">deserialize-relative-to</span> defaults to <span class="RktVar">relative-to</span>.</p><blockquote class="refpara"><blockquote class="refcolumn"><blockquote class="refcontent"><p>The <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span> and <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span> functions
|
||
|
currently do not handle certain cyclic values that <span class="RktSym"><a href="Reading.html#%28def._%28%28quote._~23~25kernel%29._read%29%29" class="RktValLink" data-pltdoc="x">read</a></span> and
|
||
|
<span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._write%29%29" class="RktValLink" data-pltdoc="x">write</a></span> can handle, such as <span class="RktVal">'</span><span class="RktVal">#0=</span><span class="RktVal">(</span><span class="RktVal">#0#</span><span class="RktVal">)</span>.</p></blockquote></blockquote></blockquote><p>See <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span> for information on the format of serialized
|
||
|
data.</p><p class="SHistory">Changed in version 6.5.0.4 of package <span class="stt">base</span>: Added keywords and regexp values as serializable.<br/>Changed in version 7.0.0.6: Added the <span class="RktPn">#:relative-directory</span> and
|
||
|
<span class="RktPn">#:deserialize-relative-directory</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><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/private/serialize..rkt)._deserialize))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValDef RktValLink" data-pltdoc="x">deserialize</a></span></span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Given a value <span class="RktVar">v</span> that was produced by <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>,
|
||
|
produces a value like the one given to <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>, including
|
||
|
the same graph structure and mutability.</div></p><p>A serialized representation <span class="RktVar">v</span> is a list of six or seven
|
||
|
elements:</p><ul><li><p>An optional list <span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">1</span><span class="RktVal">)</span>, <span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">2</span><span class="RktVal">)</span>, <span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">3</span><span class="RktVal">)</span>,
|
||
|
or <span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">4</span><span class="RktVal">)</span> that represents
|
||
|
the version of the serialization format. If the first element
|
||
|
of a representation is not a list, then the version is
|
||
|
<span class="RktVal">0</span>. Version 1 adds support for mutable pairs,
|
||
|
version 2 adds support for <a href="symbols.html#%28tech._unreadable._symbol%29" class="techoutside" data-pltdoc="x"><span class="techinside">unreadable symbols</span></a>,
|
||
|
version 3 adds support for <span class="RktSym"><a href="time.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._date%2A%29%29" class="RktValLink" data-pltdoc="x">date*</a></span> structures,
|
||
|
and version 4 adds support for paths that are meant to
|
||
|
be relative to the deserialization directory.</p></li><li><p>A non-negative exact integer <span class="RktVar">s-count</span> that represents the
|
||
|
number of distinct structure types represented in the
|
||
|
serialized data.</p></li><li><p>A list <span class="RktVar">s-types</span> of length <span class="RktVar">s-count</span>,
|
||
|
where each element represents a structure type. Each
|
||
|
structure type is encoded as a pair. 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 the
|
||
|
pair is <span class="RktVal">#f</span> for a structure whose deserialization
|
||
|
information is defined at the top level, otherwise it is a
|
||
|
quoted <a href="Module_Names_and_Loading.html#%28tech._module._path%29" class="techoutside" data-pltdoc="x"><span class="techinside">module path</span></a>, a byte string (to be converted
|
||
|
into a platform-specific path using <span class="RktSym"><a href="Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._bytes-~3epath%29%29" class="RktValLink" data-pltdoc="x">bytes->path</a></span>)
|
||
|
for a module that exports the structure’s deserialization
|
||
|
information, or a relative path element list for a module to
|
||
|
be resolved with respect to
|
||
|
<span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29" class="RktValLink" data-pltdoc="x">current-load-relative-directory</a></span> or (as a fallback)
|
||
|
<span class="RktSym"><a href="Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29" class="RktValLink" data-pltdoc="x">current-directory</a></span>; the list-of-relative-elements
|
||
|
form is produced by <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span> when
|
||
|
the <span class="RktPn">#:deserialize-relative-directory</span> argument is
|
||
|
not <span class="RktVal">#f</span>. 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> of the pair is the
|
||
|
name of a binding (at the top level or exported from a
|
||
|
module) for deserialization information, either a symbol or
|
||
|
a string representing an <a href="symbols.html#%28tech._unreadable._symbol%29" class="techoutside" data-pltdoc="x"><span class="techinside">unreadable symbol</span></a>. These two
|
||
|
are used with either <span class="RktSym">namespace-variable-binding</span> or
|
||
|
<span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29" class="RktValLink" data-pltdoc="x">dynamic-require</a></span> to obtain deserialization
|
||
|
information. See <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._make-deserialize-info%29%29" class="RktValLink" data-pltdoc="x">make-deserialize-info</a></span> for more
|
||
|
information on the binding’s value. See also
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize-module-guard%29%29" class="RktValLink" data-pltdoc="x">deserialize-module-guard</a></span>.</p></li><li><p>A non-negative exact integer, <span class="RktVar">g-count</span> that represents the
|
||
|
number of graph points contained in the following list.</p></li><li><p>A list <span class="RktVar">graph</span> of length <span class="RktVar">g-count</span>, where each element
|
||
|
represents a serialized value to be referenced during the
|
||
|
construction of other serialized values. Each list element is
|
||
|
either a box or not:</p><ul><li><p>A box represents a value that is part of a cycle, and for
|
||
|
deserialization, it must be allocated with <span class="RktVal">#f</span> for
|
||
|
each of its fields. The content of the box indicates the
|
||
|
shape of the value:</p><ul><li><p>a non-negative exact integer <span class="RktVar">i</span> for an instance
|
||
|
of a structure type that is represented by the
|
||
|
<span class="RktVar">i</span>th element of the <span class="RktVar">s-types</span> list;</p></li><li><p><span class="RktVal">'</span><span class="RktVal">c</span> for a pair, which fails on
|
||
|
deserialization (since pairs are immutable; this
|
||
|
case does not appear in output generated by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>);</p></li><li><p><span class="RktVal">'</span><span class="RktVal">m</span> for a mutable pair;</p></li><li><p><span class="RktVal">'</span><span class="RktVal">b</span> for a box;</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">v</span> and whose
|
||
|
<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 a non-negative exact integer <span class="RktVar">s</span>
|
||
|
for a vector of length <span class="RktVar">s</span>;</p></li><li><p>a list whose first element is <span class="RktVal">'</span><span class="RktVal">h</span> and whose
|
||
|
remaining elements are symbols that determine the
|
||
|
hash-table type:</p><ul><li><p><span class="RktVal">'</span><span class="RktVal">equal</span> —<wbr></wbr> <span class="RktPn">(</span><span class="RktSym"><a href="hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hash%29%29" class="RktValLink" data-pltdoc="x">make-hash</a></span><span class="RktPn">)</span></p></li><li><p><span class="RktVal">'</span><span class="RktVal">equal</span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">weak</span> —<wbr></wbr> <span class="RktPn">(</span><span class="RktSym"><a href="hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-weak-hash%29%29" class="RktValLink" data-pltdoc="x">make-weak-hash</a></span><span class="RktPn">)</span></p></li><li><p><span class="RktVal">'</span><span class="RktVal">weak</span> —<wbr></wbr> <span class="RktPn">(</span><span class="RktSym"><a href="hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-weak-hasheq%29%29" class="RktValLink" data-pltdoc="x">make-weak-hasheq</a></span><span class="RktPn">)</span></p></li><li><p>no symbols —<wbr></wbr> <span class="RktPn">(</span><span class="RktSym"><a href="hashtables.html#%28def._%28%28quote._~23~25kernel%29._make-hasheq%29%29" class="RktValLink" data-pltdoc="x">make-hasheq</a></span><span class="RktPn">)</span></p></li></ul></li><li><p><span class="RktVal">'</span><span class="RktVal">date*</span> for a <span class="RktSym"><a href="time.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._date%2A%29%29" class="RktValLink" data-pltdoc="x">date*</a></span> structure, which
|
||
|
fails on deserialization (since dates are immutable;
|
||
|
this case does not appear in output generated by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>);</p></li><li><p><span class="RktVal">'</span><span class="RktVal">date</span> for a <span class="RktSym"><a href="time.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._date%29%29" class="RktValLink" data-pltdoc="x">date</a></span> structure, which
|
||
|
fails on deserialization (since dates are immutable;
|
||
|
this case does not appear in output generated by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>);</p></li><li><p><span class="RktVal">'</span><span class="RktVal">arity-at-least</span> for an
|
||
|
<span class="RktSym"><a href="procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._arity-at-least%29%29" class="RktValLink" data-pltdoc="x">arity-at-least</a></span> structure, which fails on
|
||
|
deserialization (since arity-at-least are immutable; this
|
||
|
case does not appear in output generated by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>); or</p></li><li><p><span class="RktVal">'</span><span class="RktVal">mpi</span> for a <a href="Module_Names_and_Loading.html#%28tech._module._path._index%29" class="techoutside" data-pltdoc="x"><span class="techinside">module path index</span></a>, which
|
||
|
fails on deserialization (since a module path index is immutable;
|
||
|
this case does not appear in output generated by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>).</p></li><li><p><span class="RktVal">'</span><span class="RktVal">srcloc</span> for a <span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._srcloc%29%29" class="RktValLink" data-pltdoc="x">srcloc</a></span> structure, which
|
||
|
fails on deserialization (since srclocs are immutable;
|
||
|
this case does not appear in output generated by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>).</p></li></ul><p>The <span class="RktVal">#f</span>-filled value will be updated with content specified
|
||
|
by the fifth element of the serialization list <span class="RktVar">v</span>.</p></li><li><p>A non-box represents a <span style="font-style: italic">serial</span> value to be
|
||
|
constructed immediately, and it is one of the following:</p><ul><li><p>a boolean, number, character, interned symbol, or empty list,
|
||
|
representing itself.</p></li><li><p>a string, representing an immutable string.</p></li><li><p>a byte string, representing an immutable byte
|
||
|
string.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">?</span> and whose
|
||
|
<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 a non-negative exact integer
|
||
|
<span class="RktVar">i</span>; it represents the value constructed for the
|
||
|
<span class="RktVar">i</span>th element of <span class="RktVar">graph</span>, where <span class="RktVar">i</span> is
|
||
|
less than the position of this element within
|
||
|
<span class="RktVar">graph</span>.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is a number <span class="RktVar">i</span>; it
|
||
|
represents an instance of a structure type that is
|
||
|
described by the <span class="RktVar">i</span>th element of the
|
||
|
<span class="RktVar">s-types</span> list. 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> of the pair is
|
||
|
a list of serials representing arguments to be
|
||
|
provided to the structure type’s deserializer.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">q</span> and whose
|
||
|
<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 immutable value; it represents
|
||
|
the quoted value.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">f</span>; it
|
||
|
represents an instance of a <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a> structure
|
||
|
type. The <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cadr%29%29" class="RktValLink" data-pltdoc="x">cadr</a></span> of the pair is a <a href="structures.html#%28tech._prefab%29" class="techoutside" data-pltdoc="x"><span class="techinside">prefab</span></a>
|
||
|
structure type key, and the <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cddr%29%29" class="RktValLink" data-pltdoc="x">cddr</a></span> is a list of
|
||
|
serials representing the field values.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">void</span>,
|
||
|
representing <a href="https://download.racket-lang.org/releases/8.6/doc/local-redirect/index.html?doc=guide&rel=void_undefined.html&version=8.6" class="RktModLink Sq" data-pltdoc="x"><span class="nobreak"><span class="RktRes">#<void></span></span></a>.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">su</span> and whose
|
||
|
<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 a character string; it represents an
|
||
|
<a href="symbols.html#%28tech._unreadable._symbol%29" class="techoutside" data-pltdoc="x"><span class="techinside">unreadable symbol</span></a>.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">u</span> and whose
|
||
|
<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 either a byte string or character
|
||
|
string; it represents a mutable byte or character
|
||
|
string.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">p</span> and whose
|
||
|
<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 a byte string; it represents a
|
||
|
path using the serializer’s path convention
|
||
|
(deprecated in favor of <span class="RktVal">'</span><span class="RktVal">p+</span>).</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">p+</span>, whose
|
||
|
<span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cadr%29%29" class="RktValLink" data-pltdoc="x">cadr</a></span> is a byte string, and whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cddr%29%29" class="RktValLink" data-pltdoc="x">cddr</a></span>
|
||
|
is one of the possible symbol results of
|
||
|
<span class="RktSym"><a href="Manipulating_Paths.html#%28def._%28%28quote._~23~25kernel%29._system-path-convention-type%29%29" class="RktValLink" data-pltdoc="x">system-path-convention-type</a></span>; it represents a
|
||
|
path using the specified convention.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">p*</span> and whose
|
||
|
<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 a list of byte strings represents a
|
||
|
relative path; it will be converted by deserialization
|
||
|
based on <span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29" class="RktValLink" data-pltdoc="x">current-load-relative-directory</a></span>,
|
||
|
falling back to <span class="RktSym"><a href="Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29" class="RktValLink" data-pltdoc="x">current-directory</a></span>.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">c</span> and whose
|
||
|
<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 a pair of serials; it represents an
|
||
|
immutable pair.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">c!</span> and whose
|
||
|
<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 a pair of serials; it represents a
|
||
|
pair (but formerly represented a mutable pair), and
|
||
|
does not appear in output generated by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">m</span> and whose
|
||
|
<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 a pair of serials; it represents a
|
||
|
mutable pair.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">v</span> and whose
|
||
|
<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 a list of serials; it represents an
|
||
|
immutable vector.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">v!</span> and whose
|
||
|
<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 a list of serials; it represents a
|
||
|
mutable vector.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">vl</span> and whose
|
||
|
<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 a list of serials; it represents a
|
||
|
<a href="flonums.html#%28tech._flvector%29" class="techoutside" data-pltdoc="x"><span class="techinside">flvector</span></a>.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">vx</span> and whose
|
||
|
<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 a list of serials; it represents a
|
||
|
<a href="fixnums.html#%28tech._fxvector%29" class="techoutside" data-pltdoc="x"><span class="techinside">fxvector</span></a>.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">b</span> and whose
|
||
|
<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 a serial; it represents an immutable
|
||
|
box.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">b!</span> and whose
|
||
|
<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 a serial; it represents a mutable
|
||
|
box.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">h</span>, whose
|
||
|
<span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cadr%29%29" class="RktValLink" data-pltdoc="x">cadr</a></span> is either <span class="RktVal">'</span><span class="RktVal">!</span> or <span class="RktVal">'</span><span class="RktVal"><span class="nobreak">-</span></span>
|
||
|
(mutable or immutable, respectively), whose
|
||
|
<span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._caddr%29%29" class="RktValLink" data-pltdoc="x">caddr</a></span> is a list of symbols (containing
|
||
|
<span class="RktVal">'</span><span class="RktVal">equal</span>, <span class="RktVal">'</span><span class="RktVal">weak</span>, both, or neither)
|
||
|
that determines the hash table type, and whose
|
||
|
<span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._cdddr%29%29" class="RktValLink" data-pltdoc="x">cdddr</a></span> 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 serial for a
|
||
|
hash-table key 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 a serial for
|
||
|
the corresponding value.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">date*</span> and whose
|
||
|
<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 a list of serials; it represents a
|
||
|
<span class="RktSym"><a href="time.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._date%2A%29%29" class="RktValLink" data-pltdoc="x">date*</a></span> structure.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">date</span> and whose
|
||
|
<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 a list of serials; it represents a
|
||
|
<span class="RktSym"><a href="time.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._date%29%29" class="RktValLink" data-pltdoc="x">date</a></span> structure.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">arity-at-least</span>
|
||
|
and whose <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 a serial; it represents an
|
||
|
<span class="RktSym"><a href="procedures.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._arity-at-least%29%29" class="RktValLink" data-pltdoc="x">arity-at-least</a></span> structure.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">mpi</span> and whose
|
||
|
<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 a pair; it represents a
|
||
|
<a href="Module_Names_and_Loading.html#%28tech._module._path._index%29" class="techoutside" data-pltdoc="x"><span class="techinside">module path index</span></a> that joins the paired
|
||
|
values.</p></li><li><p>a pair whose <span class="RktSym"><a href="pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29" class="RktValLink" data-pltdoc="x">car</a></span> is <span class="RktVal">'</span><span class="RktVal">srcloc</span> and whose
|
||
|
<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 a list of serials; it represents a
|
||
|
<span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._srcloc%29%29" class="RktValLink" data-pltdoc="x">srcloc</a></span> structure.</p></li></ul></li></ul></li><li><p>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
|
||
|
non-negative exact integer <span class="RktVar">i</span> 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 a
|
||
|
serial (as defined in the previous bullet). Each element
|
||
|
represents an update to an <span class="RktVar">i</span>th element of <span class="RktVar">graph</span>
|
||
|
that was specified as a box, and the serial describes how to
|
||
|
construct a new value with the same shape as specified by the
|
||
|
box. The content of this new value must be transferred into the
|
||
|
value created for the box in <span class="RktVar">graph</span>.</p></li><li><p>A final serial (as defined in the two bullets back)
|
||
|
representing the result of <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span>.</p></li></ul><p>The result of <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span> shares no mutable values with the
|
||
|
argument to <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span>.</p><p>If a value provided to <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span> is a simple tree (i.e., no
|
||
|
sharing), then the fourth and fifth elements in the serialized
|
||
|
representation will be empty.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/private/serialize..rkt)._serialized~3d~3f))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialized~3d~3f%29%29" class="RktValDef RktValLink" data-pltdoc="x">serialized=?</a></span></span><span class="hspace"> </span><span class="RktVar">v1</span><span class="hspace"> </span><span class="RktVar">v2</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="booleans.html#%28def._%28%28quote._~23~25kernel%29._boolean~3f%29%29" class="RktValLink" data-pltdoc="x">boolean?</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v1</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v2</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span></td></tr></table></blockquote></div><div class="SIntrapara">Returns <span class="RktVal">#t</span> if <span class="RktVar">v1</span> and <span class="RktVar">v2</span> represent the same
|
||
|
serialization information.</div></p><p>More precisely, it returns the same value that <span class="RktPn">(</span><span class="RktSym"><a href="Equality.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29" class="RktValLink" data-pltdoc="x">equal?</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span><span class="stt"> </span><span class="RktVar">v1</span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span><span class="stt"> </span><span class="RktVar">v2</span><span class="RktPn">)</span><span class="RktPn">)</span> would return if</p><ul><li><p>all structure types whose deserializers are accessed with
|
||
|
distinct module paths are actually distinct types;</p></li><li><p>all structure types are transparent; and</p></li><li><p>all structure instances contain only the constituent values
|
||
|
recorded in each of <span class="RktVar">v1</span> and <span class="RktVar">v2</span>.</p></li></ul><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>parameter</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/private/serialize..rkt)._deserialize-module-guard))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize-module-guard%29%29" class="RktValDef RktValLink" data-pltdoc="x">deserialize-module-guard</a></span></span><span class="RktPn"></span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="prototype"><tr><td valign="top"><span class="hspace"> </span></td><td valign="top">→</td><td valign="top"><span class="hspace"> </span></td><td valign="top"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._module-path~3f%29%29" class="RktValLink" data-pltdoc="x">module-path?</a></span><span class="hspace"> </span><span class="RktSym"><a href="symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._or%2Fc%29%29" class="RktValLink" data-pltdoc="x">or/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._cons%2Fc%29%29" class="RktValLink" data-pltdoc="x">cons/c</a></span><span class="hspace"> </span><span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._module-path~3f%29%29" class="RktValLink" data-pltdoc="x">module-path?</a></span><span class="hspace"> </span><span class="RktSym"><a href="symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></td></tr><tr><td><span class="RktPn">(</span><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize-module-guard%29%29" class="RktValDef RktValLink" data-pltdoc="x">deserialize-module-guard</a></span></span><span class="hspace"> </span><span class="RktVar">guard</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">guard</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top">:</td><td valign="top"><span class="hspace"> </span></td><td valign="top"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym
|
||
|
dynamically loading a module via <span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29" class="RktValLink" data-pltdoc="x">dynamic-require</a></span>. The two
|
||
|
arguments provided to the procedure are the same as the arguments to
|
||
|
be passed to <span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29" class="RktValLink" data-pltdoc="x">dynamic-require</a></span>. The procedure can raise an
|
||
|
exception to disallow the <span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29" class="RktValLink" data-pltdoc="x">dynamic-require</a></span>.</div></p><p>The procedure can optionally return a pair containing a
|
||
|
<a href="Module_Names_and_Loading.html#%28tech._module._path%29" class="techoutside" data-pltdoc="x"><span class="techinside">module-path</span></a> and <a href="symbols.html#%28tech._symbol%29" class="techoutside" data-pltdoc="x"><span class="techinside">symbol</span></a>. If returned,
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span> will use them as arguments to
|
||
|
<span class="RktSym"><a href="Module_Names_and_Loading.html#%28def._%28%28quote._~23~25kernel%29._dynamic-require%29%29" class="RktValLink" data-pltdoc="x">dynamic-require</a></span> instead.</p><p class="SHistory">Changed in version 6.90.0.30 of package <span class="stt">base</span>: Adds optional return values for bindings.</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/serialize..rkt)._serializable-struct))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">serializable-struct</a></span></span><span class="hspace"> </span><span class="RktVar">id</span><span class="hspace"> </span><span class="RktVar">maybe-super</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">field</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">struct-option</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>, but instances of the structure type are
|
||
|
serializable with <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>. This form is allowed only at
|
||
|
the top level or in a module’s top level (so that deserialization
|
||
|
information can be found later).</div></p><p>Serialization supports cycles involving the created structure
|
||
|
type only when all fields are mutable (or when the cycle can be broken
|
||
|
through some other mutable value).</p><p>In addition to the bindings generated by <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>,
|
||
|
<span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span> binds
|
||
|
<span class="RktSym">deserialize-info:</span><span class="RktVar">id</span><span class="RktSym">-v0</span> to
|
||
|
deserialization information. Furthermore, in a module context, it
|
||
|
automatically <span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._provide%29%29" class="RktStxLink" data-pltdoc="x">provide</a></span>s this binding in a <span class="RktSym">deserialize-info</span>
|
||
|
submodule using <span class="RktSym"><a href="module.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._module%2B%29%29" class="RktStxLink" data-pltdoc="x">module+</a></span>.</p><p>The <span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span> form enables the construction of
|
||
|
structure instances from places where <span class="RktVar">id</span> is not accessible,
|
||
|
since deserialization must construct instances. Furthermore,
|
||
|
<span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span> provides limited access to field
|
||
|
mutation, but only for instances generated through the deserialization
|
||
|
information bound to
|
||
|
<span class="RktSym">deserialize-info:</span><span class="RktVar">id</span><span class="RktSym">-v0</span>. See
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._make-deserialize-info%29%29" class="RktValLink" data-pltdoc="x">make-deserialize-info</a></span> for more information.</p><p>Beware that the previous paragraph means that if a serializable struct
|
||
|
is exported via <span class="RktSym"><a href="attaching-contracts-to-values.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._contract-out%29%29" class="RktStxLink" data-pltdoc="x">contract-out</a></span>, for example, the contracts are not
|
||
|
checked during deserialization. Consider using <span class="RktSym"><a href="attaching-contracts-to-values.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._struct-guard%2Fc%29%29" class="RktStxLink" data-pltdoc="x">struct-guard/c</a></span>
|
||
|
instead.</p><p>The <span class="RktSym"><span class="nobreak">-v</span>0</span> suffix on the deserialization enables future
|
||
|
versioning on the structure type through
|
||
|
<span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%2Fversions%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct/versions</a></span>.</p><p>When a supertype is supplied as <span class="RktVar">maybe-super</span>,
|
||
|
compile-time information bound to the supertype identifier must
|
||
|
include all of the supertype’s field accessors. If any field mutator
|
||
|
is missing, the structure type will be treated as immutable for the
|
||
|
purposes of marshaling (so cycles involving only instances of the
|
||
|
structure type cannot be handled by the deserializer).</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">> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span><span class="hspace"> </span><span class="RktSym">point</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">point-x</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">point</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">1</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/serialize..rkt)._define-serializable-struct))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._define-serializable-struct%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-serializable-struct</a></span></span><span class="hspace"> </span><span class="RktVar">id-maybe-super</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">field</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">struct-option</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span>, but with the supertype syntax and
|
||
|
default constructor name of <span class="RktSym"><a href="define-struct.html#%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"><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/serialize..rkt)._serializable-struct/versions))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%2Fversions%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">serializable-struct/versions</a></span></span><span class="hspace"> </span><span class="RktVar">id</span><span class="hspace"> </span><span class="RktVar">maybe-super</span><span class="hspace"> </span><span class="RktVar">vers</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">field</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">(</span><span class="RktVar">other-version-clause</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">struct-option</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">other-version-clause</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktVar">other-vers</span><span class="hspace"> </span><span class="RktVar">make-proc-expr</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">cycle-make-proc-expr</span><span class="RktPn">)</span></td></tr></table></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Like <span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span>, but the generated deserializer
|
||
|
binding is
|
||
|
<span class="RktSym">deserialize-info:</span><span class="RktVar">id</span><span class="RktSym">-v</span><span class="RktVar">vers</span>. In
|
||
|
addition,
|
||
|
<span class="RktSym">deserialize-info:</span><span class="RktVar">id</span><span class="RktSym">-v</span><span class="RktVar">other-vers</span>
|
||
|
is bound for each <span class="RktVar">other-vers</span>. The <span class="RktVar">vers</span> and each
|
||
|
<span class="RktVar">other-vers</span> must be a literal, exact, nonnegative integer.</div></p><p>Each <span class="RktVar">make-proc-expr</span> should produce a procedure, and the
|
||
|
procedure should accept as many argument as fields in the
|
||
|
corresponding version of the structure type, and it produces an
|
||
|
instance of <span class="RktVar">id</span>. Each <span class="RktVar">cycle-make-proc-expr</span> should
|
||
|
produce a procedure of no arguments; this procedure should return two
|
||
|
values: an instance <span class="RktSym">x</span> of <span class="RktVar">id</span> (typically with
|
||
|
<span class="RktVal">#f</span> for all fields) and a procedure that accepts another
|
||
|
instance of <span class="RktVar">id</span> and copies its field values into <span class="RktSym">x</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">> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28form._%28%28lib._racket%2Fserialize..rkt%29._serializable-struct%29%29" class="RktStxLink" data-pltdoc="x">serializable-struct</a></span><span class="hspace"> </span><span class="RktSym">point</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">#:mutable</span><span class="hspace"> </span><span class="RktPn">#:transparent</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">> </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"> </span><span class="RktSym">ps</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">point</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">2</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span><span class="hspace"> </span><span class="RktSym">ps</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes">(point 1 2)</span></p></td></tr><tr><td><span class="stt">> </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"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">point</span><span class="hspace"> </span><span class="RktVal">1</span><span class="hspace"> </span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">set-point-x!</span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">> </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"> </span><span class="RktSym">xs</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span><span class="hspace"> </span><span class="RktSym">xs</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktRes"
|
||
|
default constructor name of <span class="RktSym"><a href="define-struct.html#%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"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/private/serialize..rkt)._make-deserialize-info))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._make-deserialize-info%29%29" class="RktValDef RktValLink" data-pltdoc="x">make-deserialize-info</a></span></span><span class="hspace"> </span><span class="RktVar">make</span><span class="hspace"> </span><span class="RktVar">cycle-make</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">make</span><span class="hspace"> </span>:<span class="hspace"> </span><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><tr><td><span class="hspace"> </span><span class="RktVar">cycle-make</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="values.html#%28def._%28%28quote._~23~25kernel%29._values%29%29" class="RktValLink" data-pltdoc="x">values</a></span><span class="hspace"> </span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><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><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Produces a deserialization information record to be used by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span>. This information is normally tied to a
|
||
|
particular structure because the structure has a
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29" class="RktValLink" data-pltdoc="x">prop:serializable</a></span> property value that points to a top-level
|
||
|
variable or module-exported variable that is bound to deserialization
|
||
|
information.</div></p><p>The <span class="RktVar">make</span> procedure should accept as many arguments as the
|
||
|
structure’s serializer put into a vector; normally, this is the number
|
||
|
of fields in the structure. It should return an instance of the
|
||
|
structure.</p><p>The <span class="RktVar">cycle-make</span> procedure should accept no arguments, and it
|
||
|
should return two values: a structure instance <span class="RktSym">x</span> (with dummy
|
||
|
field values) and an update procedure. The update procedure takes
|
||
|
another structure instance generated by the <span class="RktVar">make</span>, and it
|
||
|
transfers the field values of this instance into <span class="RktSym">x</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>value</p></div></div><p class="RForeground"><a name="(def._((lib._racket/private/serialize..rkt)._prop~3aserializable))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29" class="RktValDef RktValLink" data-pltdoc="x">prop:serializable</a></span></span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym">property?</span></p></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">This property identifies structures and structure types that are
|
||
|
serializable. The property value should be constructed with
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._make-serialize-info%29%29" class="RktValLink" data-pltdoc="x">make-serialize-info</a></span>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><table cellspacing="0" cellpadding="0" class="prototype RForeground"><tr><td valign="top"><span class="RktPn">(</span><a name="(def._((lib._racket/private/serialize..rkt)._make-serialize-info))"></a><span title="Provided from: racket/serialize | Package: base"><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._make-serialize-info%29%29" class="RktValDef RktValLink" data-pltdoc="x">make-serialize-info</a></span></span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">to-vector</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">deserialize-id</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">can-cycle?</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td></tr><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">dir</span><span class="RktPn">)</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top">→</td><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktSym"><a href="data-structure-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%29%29" class="RktStxLink" data-pltdoc="x">any</a></span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">to-vector</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="data-structure-contracts.html#%28def._%28%28lib._racket%2Fcontract%2Fprivate%2Fmisc..rkt%29._any%2Fc%29%29" class="RktValLink" data-pltdoc="x">any/c</a></span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><a href="function-contracts.html#%28form._%28%28lib._racket%2Fcontract%2Fbase..rkt%29._-~3e%29%29" class="RktStxLink" data-pltdoc="x"><span class="nobreak">-></span></a></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym"><a href="vectors.html#%28def._%28%28quote._~23~25kernel%29._vector~3f%29%29" class="RktValLink" data-pltdoc="x">vector?</a></span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td valign="top"><span class="hspace"> </span></td><td valign="top"><span class="RktVar">deserialize-id</span></td><td valign="top"><span class="hspace"> </span></td><td valign="top">:</td><td valign="top"><span class="hspace"> </span></td><td valign="top"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-s
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29" class="RktValLink" data-pltdoc="x">prop:serializable</a></span> property. This value is used by
|
||
|
<span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._serialize%29%29" class="RktValLink" data-pltdoc="x">serialize</a></span>.</div></p><p>The <span class="RktVar">to-vector</span> procedure should accept a structure instance
|
||
|
and produce a vector for the instance’s content.</p><p>The <span class="RktVar">deserialize-id</span> value indicates a binding for deserialize
|
||
|
information, to either a module export or a top-level definition. It
|
||
|
must be one of the following:</p><ul><li><p>If <span class="RktVar">deserialize-id</span> is an identifier, and if
|
||
|
<span class="RktPn">(</span><span class="RktSym"><a href="stxcmp.html#%28def._%28%28quote._~23~25kernel%29._identifier-binding%29%29" class="RktValLink" data-pltdoc="x">identifier-binding</a></span><span class="stt"> </span><span class="RktVar">deserialize-id</span><span class="RktPn">)</span> produces a list, then
|
||
|
the third element is used for the exporting module, otherwise the
|
||
|
top-level is assumed. Before trying an exporting module directly,
|
||
|
its <span class="RktSym">deserialize-info</span> submodule is tried; the module
|
||
|
itself is tried if no <span class="RktSym">deserialize-info</span>
|
||
|
submodule is available or if the export is not found. In either case, <span class="RktSym"><a href="stxops.html#%28def._%28%28quote._~23~25kernel%29._syntax-e%29%29" class="RktValLink" data-pltdoc="x">syntax-e</a></span> is used to
|
||
|
obtain the name of an exported identifier or top-level definition.</p></li><li><p>If <span class="RktVar">deserialize-id</span> is a symbol, it indicates a
|
||
|
top-level variable that is named by the symbol.</p></li><li><p>If <span class="RktVar">deserialize-id</span> is a pair, 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> must be
|
||
|
a symbol to name an exported identifier, 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> must be
|
||
|
a module path index to specify the exporting module.</p></li><li><p>If <span class="RktVar">deserialize-id</span> is a procedure, then it is
|
||
|
applied during serialization and its result is used for
|
||
|
<span class="RktVar">deserialize-id</span>.</p></li></ul><p>See <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._make-deserialize-info%29%29" class="RktValLink" data-pltdoc="x">make-deserialize-info</a></span> and <span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._deserialize%29%29" class="RktValLink" data-pltdoc="x">deserialize</a></span> for more
|
||
|
information.</p><p>The <span class="RktVar">can-cycle?</span> argument should be false if instances should
|
||
|
not be serialized in such a way that deserialization requires creating
|
||
|
a structure instance with dummy field values and then updating the
|
||
|
instance later.</p><p>The <span class="RktVar">dir</span> argument should be a directory path that is used to
|
||
|
resolve a module reference for the binding of <span class="RktVar">deserialize-id</span>.
|
||
|
This directory path is used as a last resort when
|
||
|
<span class="RktVar">deserialize-id</span> indicates a module that was loaded through a
|
||
|
relative path with respect to the top level. Usually, it should be
|
||
|
<span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._or%29%29" class="RktStxLink" data-pltdoc="x">or</a></span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="eval.html#%28def._%28%28quote._~23~25kernel%29._current-load-relative-directory%29%29" class="RktValLink" data-pltdoc="x">current-load-relative-directory</a></span><span class="RktPn">)</span><span class="stt"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Filesystem.html#%28def._%28%28quote._~23~25kernel%29._current-directory%29%29" class="RktValLink" data-pltdoc="x">current-directory</a></span><span class="RktPn">)</span><span class="RktPn">)</span>.</p><p class="SHistory">Changed in version 7.0.0.6 of package <span class="stt">base</span>: Allow <span class="RktVar">deserialize-id</span> to be a procedure.</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">> </span><span class="RktPn">(</span><span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span><span class="hspace"> </span><span class="RktSym">pie</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">type</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:mutable</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:property</span><span class="hspace"> </span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._prop~3aserializable%29%29" class="RktValLink" data-pltdoc="x">prop:serializable</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="serialization.html#%28def._%28%28lib._racket%2Fprivate%2Fserialize..rkt%29._make-serialize-info%29%29" class="RktValLink" data-pltdoc="x">make-serialize-info</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </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">λ</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="createclass.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._this%29%29" class="RktStxLink" data-pltdoc="x">this</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="vectors.html#%28def._%28%28quote._~23~25kernel%29._vector%29%29" class="RktValLink" data-pltdoc="x">vector</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">pie-type</span><span class="hspace"> </span><span class="RktSym"><a href="createclass.html#%28form._%28%28lib._racket%2Fprivate%2Fclass-internal..rkt%29._this%29%29" class="RktStxLink" data-pltdoc="x">this</a></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">pie-beam</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktVal">#t</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28lib._rac
|