interface</span> of a Unix-like operating system.</p><h4>2.1<tt> </tt><aname="(part._hashlang-variations)"></a><aname="(mod-path._marketplace)"></a>Using <spanclass="stt">#lang marketplace</span> and friends</h4><p><tablecellspacing="0"class="defmodule"><tr><tdalign="left"><spanclass="hspace"> </span><ahref="http://docs.racket-lang.org/guide/Module_Syntax.html#%28part._hash-lang%29"class="RktModLink"data-pltdoc="x"><spanclass="RktMod">#lang</span></a><spanclass="hspace"> </span><ahref="high-level-interface.html#%28mod-path._marketplace%29"class="RktModLink"data-pltdoc="x"><spanclass="RktSym">marketplace</span></a></td><tdalign="right"><spanclass="RpackageSpec"><spanclass="Smaller"> package:</span><spanclass="stt">marketplace</span></span></td></tr></table></p><p>Programs written for Marketplace differ from normal Racket modules
only in their selection of language. A Racket module written with
<spanclass="stt">#lang marketplace</span>, such as the echo server in
<ahref="Examples.html#%28part._echo-server-example%29"data-pltdoc="x">TCP echo server</a>, specifies a sequence of definitions
and startup <ahref="Concepts.html#%28tech._action%29"class="techoutside"data-pltdoc="x"><spanclass="techinside">actions</span></a> for an application. Typically, initial
actions spawn application processes and nested VMs, which in turn
subscribe to sources of events from the outside world.</p><p>At present, there’s just <spanclass="stt">#lang marketplace</span>. In future, there will
be a variation for Typed Racket, and languages providing greater
support for flow control, responsibility transfer, and other
networking concepts. For now, Typed Racket programs must be written as
<spanclass="stt">#lang typed/racket</span> programs using <spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29"class="RktStxLink"data-pltdoc="x">require</a></span><spanclass="stt"></span><spanclass="RktSym">marketplace</span><spanclass="RktPn">)</span>
and <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._ground-vm~3a%29%29"class="RktStxLink"data-pltdoc="x">ground-vm:</a></span> explicitly.</p><h4>2.2<tt> </tt><aname="(part._.Using_.Marketplace_as_a_library)"></a><aname="(mod-path._marketplace/sugar-untyped)"></a><aname="(mod-path._marketplace/sugar-typed)"></a>Using Marketplace as a library</h4><p><tablecellspacing="0"class="defmodule"><tr><tdalign="left"colspan="2"><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29"class="RktStxLink"data-pltdoc="x">require</a></span><spanclass="stt"></span><ahref="high-level-interface.html#%28mod-path._marketplace%2Fsugar-untyped%29"class="RktModLink"data-pltdoc="x"><spanclass="RktSym">marketplace/sugar-untyped</span></a><spanclass="RktPn">)</span></td></tr><tr><tdalign="left"colspan="2"><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29"class="RktStxLink"data-pltdoc="x">require</a></span><spanclass="stt"></span><ahref="high-level-interface.html#%28mod-path._marketplace%2Fsugar-typed%29"class="RktModLink"data-pltdoc="x"><spanclass="RktSym">marketplace/sugar-typed</span></a><spanclass="RktPn">)</span></td></tr><tr><tdalign="left"> </td><tdalign="right"><spanclass="RpackageSpec"><spanclass="Smaller"> package:</span><spanclass="stt">marketplace</span></span></td></tr></table></p><p>Instead of using Racket’s <spanclass="stt">#lang</span> feature, ordinary Racket programs
directly.</p><p>Such programs need to use <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._ground-vm%29%29"class="RktStxLink"data-pltdoc="x">ground-vm</a></span>/<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._ground-vm~3a%29%29"class="RktStxLink"data-pltdoc="x">ground-vm:</a></span> to
<spanclass="stt">"examples/echo-plain.rkt"</span> uses <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._ground-vm%29%29"class="RktStxLink"data-pltdoc="x">ground-vm</a></span> along with
<spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp%29%29"class="RktValLink"data-pltdoc="x">tcp</a></span> and an initial <spanclass="RktSym">endpoint</span> action:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._ground-vm%29%29"class="RktStxLink"data-pltdoc="x">ground-vm</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="Drivers.html#%28def._%28%28lib._marketplace%2Fdrivers%2Ftcp-bare..rkt%29._tcp%29%29"class="RktValLink"data-pltdoc="x">tcp</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">tcp-channel</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">tcp-listener</span><spanclass="hspace"> </span><spanclass="RktVal">5999</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-conversation%29%29"class="RktStxLink"data-pltdoc="x">match-conversation</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">tcp-channel</span><spanclass="hspace"> </span><spanclass="RktSym">from</span><spanclass="hspace"> </span><spanclass="RktSym">to</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29"class="RktStxLink"data-pltdoc="x">_</a></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-presence%29%29"class="RktStxLink"data-pltdoc="x">on-presence</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxLink"data-pltdoc="x">spawn</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">echoer</span><spanclass="hspace"> </span><spanclass="RktSym">from</span><spanclass="hspace"> </span><spanclass="RktSym">to</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._ground-vm))"></a><spantitle="Providedfrom:marketplace/s
type, for <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._ground-vm~3a%29%29"class="RktStxLink"data-pltdoc="x">ground-vm:</a></span>), it is used as the initial state for
the primordial process; if it is not supplied, the primordial process
is given <spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/void.html#%28def._%28%28quote._~23~25kernel%29._void%29%29"class="RktValLink"data-pltdoc="x">void</a></span><spanclass="RktPn">)</span> as its initial state (and <spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Void%29%29"class="RktStxLink"data-pltdoc="x">Void</a></span> as
its state type).</div></p><h4>2.3<tt> </tt><aname="(part._constructing-transitions)"></a>Constructing transitions</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-values..rkt)._transition))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktVar">new-state</span><spanclass="hspace"> </span><spanclass="RktVar">action-tree</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-typed..rkt)._transition~3a))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition~3a%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">transition:</a></span><spanclass="hspace"> </span><spanclass="RktVar">new-state</span><spanclass="hspace"> </span><spanclass="RktVar">:</span><spanclass="hspace"> </span><spanclass="RktVar">State</span><spanclass="hspace"> </span><spanclass="RktVar">action-tree</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-typed..rkt)._transition/no-state))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition%2Fno-state%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">transition/no-state</a></span><spanclass="hspace"> </span><spanclass="RktVar">action-tree</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Each of these forms produces a <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29"class="RktValLink"data-pltdoc="x">Transition</a></span> structure. The
private state), and the third for either.</div></p><p>Each <spanclass="RktVar">action-tree</span> must be an <spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action.Tree%29%29"class="RktValLink"data-pltdoc="x">ActionTree</a></span><spanclass="stt"></span><spanclass="RktVar">State</span><spanclass="RktPn">)</span>.</p><p>It’s fine to include <spanstyle="font-style: italic">no</span> action-trees, in which case the
actions.</p><p>In the case of <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition%2Fno-state%29%29"class="RktStxLink"data-pltdoc="x">transition/no-state</a></span>, the type <spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Void%29%29"class="RktStxLink"data-pltdoc="x">Void</a></span>
and value <spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/void.html#%28def._%28%28quote._~23~25kernel%29._void%29%29"class="RktValLink"data-pltdoc="x">void</a></span><spanclass="RktPn">)</span> is used for the process state.
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition%2Fno-state%29%29"class="RktStxLink"data-pltdoc="x">transition/no-state</a></span> is useful for processes that are
stateless other than the implicit state of their endpoints.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>struct</p></div></div><tablecellspacing="0"class="RForeground"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29"class="RktStxLink"data-pltdoc="x">struct</a></span></td><td><spanclass="hspace"> </span></td><td><aname="(def._((lib._marketplace/main..rkt)._transition-actions))"></a><aname="(def._((lib._marketplace/main..rkt)._transition-state))"></a><aname="(def._((lib._marketplace/main..rkt)._transition~3f))"></a><aname="(def._((lib._marketplace/main..rkt)._struct~3atransition))"></a><aname="(def._((lib._marketplace/sugar-values..rkt)._transition))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">state</span><spanclass="stt"></span><spanclass="RktSym">actions</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">#:transparent</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">state</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym">State</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktSym">actions</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action.Tree%29%29"class="RktValLink"data-pltdoc="x">ActionTree</a></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Transition))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29"class="RktValDef RktValLink"data-pltdoc="x">Transition</a></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">A transition structure. The <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._transition-state%29%29"class="RktValLink"data-pltdoc="x">transition-state</a></span> field is the new
and the <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._transition-actions%29%29"class="RktValLink"data-pltdoc="x">transition-actions</a></span> are the actions that will be
performed by the VM in order to apply the transition.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Action.Tree))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action.Tree%29%29"class="RktValDef RktValLink"data-pltdoc="x">ActionTree</a></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Constreeof%29%29"class="RktValLink"data-pltdoc="x">Constreeof</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action%29%29"class="RktValLink"data-pltdoc="x">Action</a></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>type</p></div></div><pclass="RForeground"><aname="(def._((lib._marketplace/main..rkt)._.Constreeof))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Constreeof%29%29"class="RktValDef RktValLink"data-pltdoc="x">Constreeof</a></span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.All%29%29"class="RktStxLink"data-pltdoc="x">All</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">X</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.Rec%29%29"class="RktStxLink"data-pltdoc="x">Rec</a></span><spanclass="hspace"> </span><spanclass="RktSym">CT</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types-extra..rkt%29._.U%29%29"class="RktStxLink"data-pltdoc="x">U</a></span><spanclass="hspace"> </span><spanclass="RktSym">X</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Pairof%29%29"class="RktStxLink"data-pltdoc="x">Pairof</a></span><spanclass="hspace"> </span><spanclass="RktSym">CT</span><spanclass="hspace"> </span><spanclass="RktSym">CT</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.False%29%29"class="RktStxLink"data-pltdoc="x">False</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-referenc
performing actions, a VM will traverse an action-tree in left-to-right
order.</div></p><p><spanclass="RktVal">'</span><spanclass="RktVal">(</span><spanclass="RktVal">)</span>, <spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/void.html#%28def._%28%28quote._~23~25kernel%29._void%29%29"class="RktValLink"data-pltdoc="x">void</a></span><spanclass="RktPn">)</span>, and <spanclass="RktVal">#f</span> may also be present in
action-trees: when the VM reaches such a value, it ignores it and
continues with the next leaf in the tree.</p><p>For example, all of the following are valid action trees which will
send messages <spanclass="RktVal">1</span>, <spanclass="RktVal">2</span> and <spanclass="RktVal">3</span> in that order:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29"class="RktValLink"data-pltdoc="x">list</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">1</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">2</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">3</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29"class="RktValLink"data-pltdoc="x">list</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29"class="RktValLink"data-pltdoc="x">list</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">1</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29"class="RktValLink"data-pltdoc="x">cons</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">2</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29"class="RktValLink"data-pltdoc="x">cons</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">(</span><spanclass="RktVal">)</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">3</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.or
an action-tree, <spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29"class="RktStxLink"data-pltdoc="x">and</a></span> and <spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/when_unless.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._when%29%29"class="RktStxLink"data-pltdoc="x">when</a></span> can be used to
selectively include actions in an action-tree:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29"class="RktValLink"data-pltdoc="x">list</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">first-action</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/when_unless.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._when%29%29"class="RktStxLink"data-pltdoc="x">when</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">condition?</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">optional-action</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">final-action</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29"class="RktValLink"data-pltdoc="x">list</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">first-action</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/if.html#%28form._%28%28lib._racket%2Fprivate%2Fletstx-scheme..rkt%29._and%29%29"class="RktStxLink"data-pltdoc="x">and</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">condition?</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">optional-action</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">final-action</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p>Finally, these inert placeholders can be used to represent "no action
at all" in a transition:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">new-state</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktCmt">;</span><spanclass="RktCmt"> </span><spanclass="RktCmt">No action-trees at all</span></td></tr><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">new-state</span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">(</span><spanclass="RktVal">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">new-state</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/void.html#%28def._%28%28quote._~23~25kernel%29._void%29%29"class="RktValLink"data-pltdoc="x">void</a></span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">new-state</span><spanclass="hspace"> </span><spanclass="RktVal">#f</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><tablecellspacing="0"class="prototype RForeground"><tr><td><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-values..rkt)._sequence-actions))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._sequence-actions%29%29"class="RktValDef RktValLink"data-pltdoc="x">sequence-actions</a></span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktVar">initial-transition</span></td><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td></tr><tr><td><spanclass="hspace"> </span></td><td><spanclass="hspace"> </span></td><td><spanclass="RktVar">item</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></td><td><spanclass="hspace"> </span></td><td>→</td><td><spanclass="hspace"> </span></td><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29"class="RktValLink"data-pltdoc="x">Transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">initial-transition</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29"class="RktValLink"data-pltdoc="x">Transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span></td></tr><tr><td><tab
<spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action.Tree%29%29"class="RktValLink"data-pltdoc="x">ActionTree</a></span>, it is appended to the pending transition’s
<spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._add-endpoint%29%29"class="RktValLink"data-pltdoc="x">add-endpoint</a></span>, but because endpoints are the most flexible and
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._build-endpoint%29%29"class="RktStxLink"data-pltdoc="x">build-endpoint</a></span>/<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._build-endpoint~3a%29%29"class="RktStxLink"data-pltdoc="x">build-endpoint:</a></span> form exist to give
good control over <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interest.Type%29%29"class="RktValLink"data-pltdoc="x">InterestType</a></span> in the endpoint under
see <ahref="high-level-interface.html#%28part._participating-vs-observing%29"data-pltdoc="x">Participating in a conversation vs. observing conversations</a>.</div></p><p>Almost everything is optional in an endpoint definition. The only
which case the process state type must also be specified.</p><p>For example, a minimal endpoint subscribing to all messages would be:</p><blockquoteclass="SCodeFlow"><p><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></p></blockquote><p>or in Typed Racket, for a process with <spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29"class="RktStxLink"data-pltdoc="x">Integer</a></span> as its process
state type,</p><blockquoteclass="SCodeFlow"><p><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._subscriber~3a%29%29"class="RktStxLink"data-pltdoc="x">subscriber:</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29"class="RktStxLink"data-pltdoc="x">Integer</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></p></blockquote><p>A minimal publishing endpoint would be:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._publisher%29%29"class="RktStxLink"data-pltdoc="x">publisher</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._publisher~3a%29%29"class="RktStxLink"data-pltdoc="x">publisher:</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Integer%29%29"class="RktStxLink"data-pltdoc="x">Integer</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span></td></tr></table></blockquote><p>While topic patterns are ordinary Racket data with embedded <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span>
note that <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span> is a wildcard in a topic pattern, while
<spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29"class="RktStxLink"data-pltdoc="x">_</a></span> is a wildcard in a <spanclass="RktSym">match</span>-pattern.</p><h5>2.4.1<tt> </tt><aname="(part._.Receiving_messages)"></a>Receiving messages</h5><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._on-message))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">on-message</a></span><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktVar">pattern</span><spanclass="hspace"> </span><spanclass="RktVar">expr</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">]</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">Supply an <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxLink"data-pltdoc="x">on-message</a></span> handler clause to an endpoint definition
<spanstyle="font-style: italic">handles</span> some of them:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxLink"data-pltdoc="x">on-message</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktVal">'</span><spanclass="RktVal">ping</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">pong</span><spanclass="RktPn">)</span><spanclass="RktPn">]</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktVal">'</span><spanclass="RktVal">hello</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29"class="RktValLink"data-pltdoc="x">list</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">goodbye</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._quit%29%29"class="RktValLink"data-pltdoc="x">quit</a></span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">]</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><h5>2.4.2<tt> </tt><aname="(part._.Action-only_vs__.State_updates)"></a>Action-only vs. State updates</h5><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._match-state))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-state%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">match-state</a></span><spanclass="hspace"> </span><spanclass="RktVar">pattern</span><spanclass="hspace"> </span><spanclass="RktVar">handler</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">If a group of handlers is wrapped in <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-state%29%29"class="RktStxLink"data-pltdoc="x">match-state</a></span>, then all
<ahref="high-level-interface.html#%28part._constructing-transitions%29"data-pltdoc="x">transition structures</a>.</div></p><p>If not, however, the handler expressions are expected to return plain
<spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action.Tree%29%29"class="RktValLink"data-pltdoc="x">ActionTree</a></span>s.</p><p>This way, simple handlers that do not need to examine the process
value through the code.</p><p>For example, a simple endpoint could be written either as</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">ping</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxLink"data-pltdoc="x">on-message</a></span><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktVal">'</span><spanclass="RktVal">ping</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">pong</span><spanclass="RktPn">)</span><spanclass="RktPn">]</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p>or, explicitly accessing the endpoint’s process’s state,</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">ping</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-state%29%29"class="RktStxLink"data-pltdoc="x">match-state</a></span><spanclass="hspace"> </span><spanclass="RktSym">old-state</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxLink"data-pltdoc="x">on-message</a></span><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktVal">'</span><spanclass="RktVal">ping</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxLink"data-pltdoc="x">transition</a></span><spanclass="hspace"> </span><spanclass="RktSym">old-state</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">pong</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">]</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><h5>2.4.3<tt> </tt><aname="(part._.Handling_presence_and_absence_events)"></a>Handling presence and absence events</h5><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._market
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-presence%29%29"class="RktStxLink"data-pltdoc="x">on-presence</a></span> and <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-absence%29%29"class="RktStxLink"data-pltdoc="x">on-absence</a></span> handlers override this
behaviour.</p><p>For example, say process A establishes the following endpoint:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">ping</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-presence%29%29"class="RktStxLink"data-pltdoc="x">on-presence</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">pinger-arrived</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-absence%29%29"class="RktStxLink"data-pltdoc="x">on-absence</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">pinger-departed</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxLink"data-pltdoc="x">on-message</a></span><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktVal">'</span><spanclass="RktVal">ping</span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">pong</span><spanclass="RktPn">)</span><spanclass="RktPn">]</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p>Some time later, process B takes the following endpoint-establishing
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-presence%29%29"class="RktStxLink"data-pltdoc="x">on-presence</a></span> handler runs, installing a second endpoint
and sending the <spanclass="RktVal">'</span><spanclass="RktVal">ping</span> message.</p></li><li><p>Process A’s endpoint receives the <spanclass="RktVal">'</span><spanclass="RktVal">ping</span> message, and
sends the <spanclass="RktVal">'</span><spanclass="RktVal">pong</span> message.</p></li><li><p>Process B’s second endpoint receives the <spanclass="RktVal">'</span><spanclass="RktVal">pong</span>
message, and deletes both of process B’s endpoints.</p></li><li><p>The <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-absence%29%29"class="RktStxLink"data-pltdoc="x">on-absence</a></span> handler in process A runs, sending
the <spanclass="RktVal">'</span><spanclass="RktVal">pinger-departed</span> message.</p></li></ol><p>One possible trace of messages in the VM containing processes A and B is</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktVal">'</span><spanclass="RktVal">pinger-arrived</span></td></tr><tr><td><spanclass="RktVal">'</span><spanclass="RktVal">ping</span></td></tr><tr><td><spanclass="RktVal">'</span><spanclass="RktVal">pong</span></td></tr><tr><td><spanclass="RktVal">'</span><spanclass="RktVal">pinger-departed</span></td></tr></table></blockquote><p>By sending the <spanclass="RktVal">'</span><spanclass="RktVal">ping</span> message <spanstyle="font-style: italic">only</span> once the
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-presence%29%29"class="RktStxLink"data-pltdoc="x">on-presence</a></span> handler has fired, process B ensures that
issuing any.</p><h5>2.4.4<tt> </tt><aname="(part._.Exit_reasons)"></a>Exit reasons</h5><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._match-reason))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-reason%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">match-reason</a></span><spanclass="hspace"> </span><spanclass="RktVar">pattern</span><spanclass="hspace"> </span><spanclass="RktVar">handler</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">If a handler is wrapped in a <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-reason%29%29"class="RktStxLink"data-pltdoc="x">match-reason</a></span> form, then the exit
reason supplied to the <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29"class="RktValLink"data-pltdoc="x">delete-endpoint</a></span> or <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._quit%29%29"class="RktValLink"data-pltdoc="x">quit</a></span>
action that led to the <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event%29%29"class="RktValLink"data-pltdoc="x">absence-event</a></span> is available to the
endpoint’s <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-absence%29%29"class="RktStxLink"data-pltdoc="x">on-absence</a></span> handler expression.</div></p><h5>2.4.5<tt> </tt><aname="(part._updating-endpoints)"></a>Updating endpoints</h5><p>If, when an endpoint is created, an existing endpoint with an
<spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29"class="RktValLink"data-pltdoc="x">equal?</a></span> name is already present, then if the existing and
to-be-added endpoints have exactly equal roles (meaning equal
orientations, interest-types, and topic patterns), the <spanstyle="font-style: italic">handlers</span>
for the endpoint are <spanstyle="font-style: italic">updated</span> without emitting presence or
absence notifications.</p><p>This dubious feature can be used to avoid "glitching" of presence
signals. A future release of this library will include better
automatic support for avoiding such transients.</p><h5>2.4.6<tt> </tt><aname="(part._.Who_am_.I_talking_to_)"></a>Who am I talking to?</h5><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._match-orientation))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-orientation%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">match-orientation</a></span><spanclass="hspace"> </span><spanclass="RktVar">pattern</span><spanclass="hspace"> </span><spanclass="RktVar">handler</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._match-conversation))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-conversation%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">match-conversation</a></span><spanclass="hspace"> </span><spanclass="RktVar">pattern</span><spanclass="hspace"> </span><spanclass="RktVar">handler</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._match-interest-type))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-interest-type%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">match-interest-type</a></span><spanclass="hspace"> </span><spanclass="RktVar">pattern</span><spanclass="hspace"> </span><spanclass="RktVar">handler</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Wrapping a handler in <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-orientation%29%29"class="RktStxLink"data-pltdoc="x">match-orientation</a></span>,
a handler access to the contents of the <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role%29%29"class="RktValLink"data-pltdoc="x">role</a></span> structure
carried in the triggering <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Endpoint.Event%29%29"class="RktValLink"data-pltdoc="x">EndpointEvent</a></span>.</div></p><p>The carried role describes the <spanstyle="font-style: italic">intersection of interests</span>
between the current endpoint and the peer endpoint, and so can proxy
for the identity of the other party. It is in a sense a description of
the scope of the current conversation.</p><p>It is most common to simply use <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-conversation%29%29"class="RktStxLink"data-pltdoc="x">match-conversation</a></span> to extract
the <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role-topic%29%29"class="RktValLink"data-pltdoc="x">role-topic</a></span> alone, since it is seldom necessary to examine
<spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role-orientation%29%29"class="RktValLink"data-pltdoc="x">role-orientation</a></span> (since it’s guaranteed to be complementary
<spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role-interest-type%29%29"class="RktValLink"data-pltdoc="x">role-interest-type</a></span>.</p><p>See <ahref="Examples.html"data-pltdoc="x">Examples</a> for examples of the use of
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._match-conversation%29%29"class="RktStxLink"data-pltdoc="x">match-conversation</a></span> and friends.</p><h5>2.4.7<tt> </tt><aname="(part._participating-vs-observing)"></a>Participating in a conversation vs. observing conversations</h5><p>The core <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._build-endpoint%29%29"class="RktStxLink"data-pltdoc="x">build-endpoint</a></span> form takes an expression evaluating
to a <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._role%29%29"class="RktValLink"data-pltdoc="x">role</a></span>, rather than a simple topic. This gives full
control over the new endpoint’s <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Orientation%29%29"class="RktValLink"data-pltdoc="x">Orientation</a></span> and
<spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Interest.Type%29%29"class="RktValLink"data-pltdoc="x">InterestType</a></span>.</p><p>The other forms exist for convenience, since usually the orientation
and interest-type is known statically, and only the topic varies
dynamically:</p><ul><li><p><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._publisher%29%29"class="RktStxLink"data-pltdoc="x">publisher</a></span> and <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span> (and typed
conversations;</p></li><li><p><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-subscribers%29%29"class="RktStxLink"data-pltdoc="x">observe-subscribers</a></span> and <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-publishers%29%29"class="RktStxLink"data-pltdoc="x">observe-publishers</a></span>
are for <spanstyle="font-style: italic">observing</span> conversations without participating in them; and</p></li><li><p><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-subscribers%2Feverything%29%29"class="RktStxLink"data-pltdoc="x">observe-subscribers/everything</a></span> and
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-publishers%2Feverything%29%29"class="RktStxLink"data-pltdoc="x">observe-publishers/everything</a></span> are like the ordinary
instead of <spanclass="RktVal">'</span><spanclass="RktVal">observer</span>.</p></li></ul><p>The <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._publisher%29%29"class="RktStxLink"data-pltdoc="x">publisher</a></span>, <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-subscribers%29%29"class="RktStxLink"data-pltdoc="x">observe-subscribers</a></span> and
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-subscribers%2Feverything%29%29"class="RktStxLink"data-pltdoc="x">observe-subscribers/everything</a></span> forms create
<spanstyle="font-style: italic">publisher</span>-oriented endpoints, and <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span>,
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-publishers%29%29"class="RktStxLink"data-pltdoc="x">observe-publishers</a></span> and <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._observe-publishers%2Feverything%29%29"class="RktStxLink"data-pltdoc="x">observe-publishers/everything</a></span>
but as an observer, the code should declare the roles being observed.</p><h5>2.4.8<tt> </tt><aname="(part._naming-endpoints)"></a>Naming endpoints</h5><p>Endpoint names can be used to <ahref="high-level-interface.html#%28part._updating-endpoints%29"data-pltdoc="x">update</a>
or <ahref="high-level-interface.html#%28part._deleting-endpoints%29"data-pltdoc="x">delete</a> endpoints.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-typed..rkt)._name-endpoint))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-typed..rkt%29._name-endpoint%29%29"class="RktValDef RktValLink"data-pltdoc="x">name-endpoint</a></span><spanclass="hspace"> </span><spanclass="RktVar">id</span><spanclass="hspace"> </span><spanclass="RktVar">add-endpoint-action</span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Add.Endpoint%29%29"class="RktValLink"data-pltdoc="x">AddEndpoint</a></span></p></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">id</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">add-endpoint-action</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Add.Endpoint%29%29"class="RktValLink"data-pltdoc="x">AddEndpoint</a></span></td></tr></table></blockquote></div><divclass="SIntrapara">Returns a copy of the passed-in <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._add-endpoint%29%29"class="RktValLink"data-pltdoc="x">add-endpoint</a></span> action
value.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._let-fresh))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._let-fresh%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">let-fresh</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktVar">identifier</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktVar">expr</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></blockquote></div><divclass="SIntrapara">Binds the <spanclass="RktVar">identifier</span>s to freshly-gensymmed symbols so that
they are available to the <spanclass="RktSym">exprs</span>. <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._let-fresh%29%29"class="RktStxLink"data-pltdoc="x">let-fresh</a></span> is useful
for inventing a guaranteed-unused name for a temporary endpoint:</div></p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._let-fresh%29%29"class="RktStxLink"data-pltdoc="x">let-fresh</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">my-name</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-typed..rkt%29._name-endpoint%29%29"class="RktValLink"data-pltdoc="x">name-endpoint</a></span><spanclass="hspace"> </span><spanclass="RktSym">my-name</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._on-message%29%29"class="RktStxLink"data-pltdoc="x">on-message</a></span><spanclass="hspace"> </span><spanclass="RktPn">[</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29.__%29%29"class="RktStxLink"data-pltdoc="x">_</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._list%29%29"class="RktValLink"data-pltdoc="x">list</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29"class="RktValLink"data-pltdoc="x">delete-endpoint</a></span><spanclass="hspace"> </span><spanclass="RktSym">my-name</span><spanclass="RktPn">)</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktMeta"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29"class="RktStxLink"data-pltdoc="x">...</a></span><spanclass="RktPn">)</span><spanclass="RktPn">]</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><h4>2.5<tt> </tt><aname="(part._deleting-endpoints)"></a>Deleting endpoints</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-values..rkt)._delete-endpoint))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._delete-endpoint%29%29"class="RktValDef RktValLink"data-pltdoc="x">delete-endpoint</a></span><spanclass="hspace"> </span><spanclass="RktVar">id</span><spanclass="hspace"> </span>[<spanclass="RktVar">reason</span>]<spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%
<spanclass="RktVar">id</span> given must be <spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29"class="RktValLink"data-pltdoc="x">equal?</a></span> to the corresponding
<spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._add-endpoint-pre-eid%29%29"class="RktValLink"data-pltdoc="x">add-endpoint-pre-eid</a></span>; when <spanclass="RktSym">endpoint</span> was used to
<ahref="high-level-interface.html#%28part._naming-endpoints%29"data-pltdoc="x">Naming endpoints</a>.</div></p><p>If <spanclass="RktVar">reason</span> is supplied, it is included in the corresponding
action, and made available in any resulting <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event%29%29"class="RktValLink"data-pltdoc="x">absence-event</a></span>s.</p><h4>2.6<tt> </tt><aname="(part._.Sending_messages_and_feedback)"></a>Sending messages and feedback</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-values..rkt)._send-message))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValDef RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVar">body</span><spanclass="hspace"> </span>[<spanclass="RktVar">orientation</span>]<spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action%29%29"class="RktValLink"data-pltdoc="x">Action</a></span></p></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">body</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">orientation</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Orientation%29%29"class="RktValLink"data-pltdoc="x">Orientation</a></span><spanclass="hspace"> </span>=<spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">publisher</span></td></tr></table></blockquote></div><divclass="SIntrapara">Constructs a message-sending action with the given orientation.
role, i.e. sending feedback.</div></p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-values..rkt)._send-feedback))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-feedback%29%29"class="RktValDef RktValLink"data-pltdoc="x">send-feedback</a></span><spanclass="hspace"> </span><spanclass="RktVar">body</span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action%29%29"class="RktValLink"data-pltdoc="x">Action</a></span></p></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">body</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr></table></blockquote></div><divclass="SIntrapara">Equivalent to <spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="stt"></span><spanclass="RktVar">body</span><spanclass="stt"></span><spanclass="RktVal">'</span><spanclass="RktVal">subscriber</span><spanclass="RktPn">)</span>.</div></p><h4>2.7<tt> </tt><aname="(part._.Creating_processes)"></a>Creating processes</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._spawn))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">spawn</a></span><spanclass="hspace"> </span><spanclass="RktVar">maybe-pid-binding</span><spanclass="hspace"> </span><spanclass="RktVar">boot-expr</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><tablecellspacing="0"class="RktBlk RForeground"><tr><td><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._spawn/continue))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%2Fcontinue%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">spawn/continue</a></span><spanclass="hspace"> </span><spanclass="RktVar">maybe-pid-binding</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">#:parent</span><spanclass="hspace"> </span><spanclass="RktVar">parent-state-pattern</span><spanclass="hspace"> </span><spanclass="RktVar">k-expr</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">#:child</span><spanclass="hspace"> </span><spanclass="RktVar">boot-expr</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow
should be an expression yielding a <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-values..rkt%29._transition%29%29"class="RktStxLink"data-pltdoc="x">transition</a></span> that contains
the child process’s initial state and initial actions.</div></p><p>If <spanclass="RktPn">#:pid</span> is supplied, the associated identifier is bound to
the child process’s PID in both <spanclass="RktVar">boot-expr</span> and the parent’s
<spanclass="RktVar">k-expr</span>.</p><p>The <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%2Fcontinue%29%29"class="RktStxLink"data-pltdoc="x">spawn/continue</a></span> and <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._spawn%2Fcontinue~3a%29%29"class="RktStxLink"data-pltdoc="x">spawn/continue:</a></span> variations
return a <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29"class="RktValLink"data-pltdoc="x">Transition</a></span>, since <spanclass="RktVar">parent-state-pattern</span> is
always supplied for these variations.</p><p>In Typed Racket, for type system reasons, <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._spawn~3a%29%29"class="RktStxLink"data-pltdoc="x">spawn:</a></span> and
<spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._spawn%2Fcontinue~3a%29%29"class="RktStxLink"data-pltdoc="x">spawn/continue:</a></span> require <spanclass="RktVar">ParentStateType</span> to be
supplied as well as <spanclass="RktVar">ChildStateType</span>.</p><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-typed..rkt)._name-process))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-typed..rkt%29._name-process%29%29"class="RktValDef RktValLink"data-pltdoc="x">name-process</a></span><spanclass="hspace"> </span><spanclass="RktVar">id</span><spanclass="hspace"> </span><spanclass="RktVar">spawn-action</span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Spawn%29%29"class="RktValLink"data-pltdoc="x">Spawn</a></span></p></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">id</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">spawn-action</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Spawn%29%29"class="RktValLink"data-pltdoc="x">Spawn</a></span></td></tr></table></blockquote></div><divclass="SIntrapara">Returns a copy of the passed-in <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxLink"data-pltdoc="x">spawn</a></span> action structure, with
<ahref="Management_and_Monitoring.html#%28part._logging%29"data-pltdoc="x">logging (MARKETPLACE_LOG)</a>.</div></p><h4>2.8<tt> </tt><aname="(part._.Exiting_and_killing_processes)"></a>Exiting and killing processes</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-values..rkt)._quit))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._quit%29%29"class="RktValDef RktValLink"data-pltdoc="x">quit</a></span><spanclass="hspace"> </span>[<spanclass="RktVar">who</span><spanclass="hspace"> </span><spanclass="RktVar">reason</span>]<spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action%29%29"class="RktValLink"data-pltdoc="x">Action</a></span></p></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">who</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Option%29%29"class="RktStxLink"data-pltdoc="x">Option</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.P.I.D%29%29"class="RktValLink"data-pltdoc="x">PID</a></span><spanclass="RktPn">)</span><spanclass="hspace"> </span>=<spanclass="hspace"> </span><spanclass="RktVal">#f</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">reason</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Any%29%29"class="RktStxLink"data-pltdoc="x">Any</a></span><spanclass="hspace"> </span>=<spanclass="hspace"> </span><spanclass="RktVal">#f</span></td></tr></table></blockquote></div><divclass="SIntrapara">Action causing the termination of a process. If <spanclass="RktVar">who</span> is
omitted or <spanclass="RktVal">#f</span>, terminates the acting process; otherwise,
terminates the peer process having <spanclass="RktVar">who</span> as its PID.</div></p><p>If <spanclass="RktVar">reason</span> is supplied, it is included in the corresponding
action, and made available in any resulting <spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._absence-event%29%29"class="RktValLink"data-pltdoc="x">absence-event</a></span>s.</p><p>Terminating the current process is as simple as:</p><blockquoteclass="SCodeFlow"><p><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._quit%29%29"class="RktValLink"data-pltdoc="x">quit</a></span><spanclass="RktPn">)</span></p></blockquote><p>When a process raises an exception that it does not catch, its
itself.</p><h4>2.9<tt> </tt><aname="(part._.Cooperative_scheduling)"></a>Cooperative scheduling</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._yield))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._yield%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">yield</a></span><spanclass="hspace"> </span><spanclass="RktVar">state-pattern</span><spanclass="hspace"> </span><spanclass="RktVar">k-expr</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-typed..rkt)._yield~3a))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._yield~3a%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">yield:</a></span><spanclass="hspace"> </span><spanclass="RktVar">state-pattern</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29"class="RktStxLink"data-pltdoc="x">:</a></span><spanclass="hspace"> </span><spanclass="RktVar">State</span><spanclass="hspace"> </span><spanclass="RktVar">k-expr</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Lets other processes in the system run for a step, returning to
<spanclass="RktVar">k-expr</span> must evaluate to a <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Transition%29%29"class="RktValLink"data-pltdoc="x">Transition</a></span>.</p><h4>2.10<tt> </tt><aname="(part._.Creating_nested_.V.Ms)"></a>Creating nested VMs</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><tablecellspacing="0"class="RktBlk RForeground"><tr><td><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-untyped..rkt)._spawn-vm))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn-vm%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">spawn-vm</a></span><spanclass="hspace"> </span><spanclass="RktVar">maybe-vm-pid-binding</span><spanclass="hspace"> </span><spanclass="RktVar">maybe-boot-pid-binding</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">maybe-initial-state</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">maybe-debug-name</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">boot-action-expr</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><tablecellspacing="0"class="RktBlk RForeground"><tr><td><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-typed..rkt)._spawn-vm~3a))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._spawn-vm~3a%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">spawn-vm:</a></span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/ts-reference/special-forms.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fprims..rkt%29._~3a%29%29"class="RktStxLink"data-pltdoc="x">:</a></span><spanclass="hspace"> </span><spanclass="RktVar">ParentStateType</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">maybe-vm-pid-binding</span><spanclass="hspace"> </span><spanclass="RktVar">maybe-boot-pid-binding</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">maybe-typed-initial-state</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">maybe-debug-name</span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">boot-action-expr</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><spanclass="stt"> </span></td></tr><tr><td><tablecellspacing="0"class="specgrammar"><tr><tdalign="right"valign="baseline"><spanclass="RktVar">maybe-vm-pid-binding</span></td><tdalign="left"valign="baseline"><spanclass="stt"> </span></td><tdalign="center"valign="baseline">=</td><tdalign="left"valign="baseline"><spanclass="stt"> </span></td><tdalign="left"valign="baseline"><tablecellspacing="0"class="RktBlk"><tr><td></td></tr></table></td></tr><tr><tdalign="right"valign="baseline"><spanclass="stt"> </span></td><tdalign="left"valign="baseline"><spanclass="stt"> </span></td><tdalig
primordial process in the new VM executes the boot-actions with the
given initial state. (If no initial state is supplied, <spanclass="RktPn">(</span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/void.html#%28def._%28%28quote._~23~25kernel%29._void%29%29"class="RktValLink"data-pltdoc="x">void</a></span><spanclass="RktPn">)</span>
is used.)</div></p><p>If <spanclass="RktPn">#:vm-pid</span> is present, the corresponding identifier is bound
in the boot-action expressions to the container-relative PID of the
new VM itself. If <spanclass="RktPn">#:boot-pid</span> is present, however, the
corresponding identifier is bound to the new-VM-relative PID of the
primordial process in the new VM.</p><h4>2.11<tt> </tt><aname="(part._.Relaying_across_layers)"></a>Relaying across layers</h4><p><divclass="SIntrapara"><blockquoteclass="SVInsetFlow"><tablecellspacing="0"class="boxed RBoxed"><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>syntax</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(form._((lib._marketplace/sugar-typed..rkt)._at-meta-level~3a))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._at-meta-level~3a%29%29"class="RktStxDef RktStxLink"data-pltdoc="x">at-meta-level:</a></span><spanclass="hspace"> </span><spanclass="RktVar">StateType</span><spanclass="hspace"> </span><spanclass="RktVar">preaction</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span></p></blockquote></td></tr></table></td></tr><tr><td><tablecellspacing="0"class="together"><tr><td><blockquoteclass="SubFlow"><divclass="RBackgroundLabel SIEHidden"><divclass="RBackgroundLabelInner"><p>procedure</p></div></div><pclass="RForeground"><spanclass="RktPn">(</span><aname="(def._((lib._marketplace/sugar-untyped..rkt)._at-meta-level))"></a><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29"class="RktValDef RktValLink"data-pltdoc="x">at-meta-level</a></span><spanclass="hspace"> </span><spanclass="RktVar">preaction</span><spanclass="hspace"> </span><spanclass="RktMeta">...</span><spanclass="RktPn">)</span><spanclass="hspace"> </span>→<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Action%29%29"class="RktValLink"data-pltdoc="x">Action</a></span><spanclass="hspace"> </span><spanclass="RktVar">StateType</span><spanclass="RktPn">)</span></p></blockquote></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktVar">preaction</span><spanclass="hspace"> </span>:<spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fmain..rkt%29._.Pre.Action%29%29"class="RktValLink"data-pltdoc="x">PreAction</a></span><spanclass="hspace"> </span><spanclass="RktSym">State</span><spanclass="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><divclass="SIntrapara">Each VM gives its processes access to two distinct IPC facilities: the
using <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29"class="RktValLink"data-pltdoc="x">at-meta-level</a></span> (or <spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._at-meta-level~3a%29%29"class="RktStxLink"data-pltdoc="x">at-meta-level:</a></span> in typed
apply at the level of the acting process’s VM’s container instead.</p><p>For example, wrapping an <spanclass="RktSym">endpoint</span> in <spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29"class="RktValLink"data-pltdoc="x">at-meta-level</a></span>
endpoint in the VM’s own network, the ground VM:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn-vm%29%29"class="RktStxLink"data-pltdoc="x">spawn-vm</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29"class="RktValLink"data-pltdoc="x">at-meta-level</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._subscriber%29%29"class="RktStxLink"data-pltdoc="x">subscriber</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">tcp-channel</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym">tcp-listener</span><spanclass="hspace"> </span><spanclass="RktVal">5999</span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="low-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._~3f%29%29"class="RktValLink"data-pltdoc="x">?</a></span><spanclass="RktPn">)</span><spanclass="hspace"> </span><spanclass="RktSym"><ahref="http://docs.racket-lang.org/reference/stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29"class="RktStxLink"data-pltdoc="x">...</a></span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p>In this example, a new process is spawned as a sibling of the
nested VM rather than as a sibling of its primordial process:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn-vm%29%29"class="RktStxLink"data-pltdoc="x">spawn-vm</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._at-meta-level%29%29"class="RktValLink"data-pltdoc="x">at-meta-level</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxLink"data-pltdoc="x">spawn</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition%2Fno-state%29%29"class="RktStxLink"data-pltdoc="x">transition/no-state</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">hello-world</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><p>Compare to this example, which spawns a sibling of the
nested VM’s primordial process:</p><blockquoteclass="SCodeFlow"><tablecellspacing="0"class="RktBlk"><tr><td><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn-vm%29%29"class="RktStxLink"data-pltdoc="x">spawn-vm</a></span></td></tr><tr><td><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-untyped..rkt%29._spawn%29%29"class="RktStxLink"data-pltdoc="x">spawn</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28form._%28%28lib._marketplace%2Fsugar-typed..rkt%29._transition%2Fno-state%29%29"class="RktStxLink"data-pltdoc="x">transition/no-state</a></span><spanclass="hspace"> </span><spanclass="RktPn">(</span><spanclass="RktSym"><ahref="high-level-interface.html#%28def._%28%28lib._marketplace%2Fsugar-values..rkt%29._send-message%29%29"class="RktValLink"data-pltdoc="x">send-message</a></span><spanclass="hspace"> </span><spanclass="RktVal">'</span><spanclass="RktVal">hello-world</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span><spanclass="RktPn">)</span></td></tr></table></blockquote><divclass="navsetbottom"><spanclass="navleft"> </span><spanclass="navright"> <ahref="Concepts.html"title="backward to "1 Concepts""data-pltdoc="x">← prev</a> <ahref="index.html"title="up to "Marketplace: Network-Aware Programming""data-pltdoc="x">up</a> <ahref="low-level-interface.html"title="forward to "3 Low-level interface""data-pltdoc="x">next →</a></span> </div></div></div><divid="contextindicator"> </div></body></html>