/usr/share/doc/racket/reference/struct-generics.html is in racket-doc 6.1-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><title>5.4 Generic Interfaces</title><link rel="stylesheet" type="text/css" href="../scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="extras.css" title="default"/><link rel="stylesheet" type="text/css" href="../racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../manual-racket.css" title="default"/><link rel="stylesheet" type="text/css" href="../doc-site.css" title="default"/><script type="text/javascript" src="../scribble-common.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../manual-racket.js"></script><script type="text/javascript" src="../doc-site.js"></script><script type="text/javascript" src="../local-redirect/local-redirect.js"></script><script type="text/javascript" src="../local-redirect/local-user-redirect.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="doc-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_0");">►</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x"><span style="font-weight: bold">The Racket Reference</span></a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1 </td><td><a href="model.html" class="tocviewlink" data-pltdoc="x">Language Model</a></td></tr><tr><td align="right">2 </td><td><a href="notation.html" class="tocviewlink" data-pltdoc="x">Notation for Documentation</a></td></tr><tr><td align="right">3 </td><td><a href="syntax.html" class="tocviewlink" data-pltdoc="x">Syntactic Forms</a></td></tr><tr><td align="right">4 </td><td><a href="data.html" class="tocviewlink" data-pltdoc="x">Datatypes</a></td></tr><tr><td align="right">5 </td><td><a href="structures.html" class="tocviewselflink" data-pltdoc="x">Structures</a></td></tr><tr><td align="right">6 </td><td><a href="mzlib_class.html" class="tocviewlink" data-pltdoc="x">Classes and Objects</a></td></tr><tr><td align="right">7 </td><td><a href="mzlib_unit.html" class="tocviewlink" data-pltdoc="x">Units</a></td></tr><tr><td align="right">8 </td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">Contracts</a></td></tr><tr><td align="right">9 </td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">Pattern Matching</a></td></tr><tr><td align="right">10 </td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">Control Flow</a></td></tr><tr><td align="right">11 </td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">Concurrency and Parallelism</a></td></tr><tr><td align="right">12 </td><td><a href="Macros.html" class="tocviewlink" data-pltdoc="x">Macros</a></td></tr><tr><td align="right">13 </td><td><a href="input-and-output.html" class="tocviewlink" data-pltdoc="x">Input and Output</a></td></tr><tr><td align="right">14 </td><td><a href="security.html" class="tocviewlink" data-pltdoc="x">Reflection and Security</a></td></tr><tr><td align="right">15 </td><td><a href="os.html" class="tocviewlink" data-pltdoc="x">Operating System</a></td></tr><tr><td align="right">16 </td><td><a href="memory.html" class="tocviewlink" data-pltdoc="x">Memory Management</a></td></tr><tr><td align="right">17 </td><td><a href="unsafe.html" class="tocviewlink" data-pltdoc="x">Unsafe Operations</a></td></tr><tr><td align="right">18 </td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">Running Racket</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,"tocview_1");">▼</a></td><td>5 </td><td><a href="structures.html" class="tocviewlink" data-pltdoc="x">Structures</a></td></tr></table><div class="tocviewsublistbottom" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">5.1 </td><td><a href="define-struct.html" class="tocviewlink" data-pltdoc="x">Defining Structure Types:<span class="mywbr"> </span> <span class="RktSym"><span class="RktStxLink">struct</span></span></a></td></tr><tr><td align="right">5.2 </td><td><a href="creatingmorestructs.html" class="tocviewlink" data-pltdoc="x">Creating Structure Types</a></td></tr><tr><td align="right">5.3 </td><td><a href="structprops.html" class="tocviewlink" data-pltdoc="x">Structure Type Properties</a></td></tr><tr><td align="right">5.4 </td><td><a href="" class="tocviewselflink" data-pltdoc="x">Generic Interfaces</a></td></tr><tr><td align="right">5.5 </td><td><a href="struct-copy.html" class="tocviewlink" data-pltdoc="x">Copying and Updating Structures</a></td></tr><tr><td align="right">5.6 </td><td><a href="structutils.html" class="tocviewlink" data-pltdoc="x">Structure Utilities</a></td></tr><tr><td align="right">5.7 </td><td><a href="structinfo.html" class="tocviewlink" data-pltdoc="x">Structure Type Transformer Binding</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define-generics%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define-<wbr></wbr>generics</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fgeneric..rkt%29._raise-support-error%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">raise-<wbr></wbr>support-<wbr></wbr>error</span></span></a></td></tr><tr><td><a href="#%28def._%28%28lib._racket%2Fgeneric..rkt%29._exn~3afail~3asupport%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktValLink">exn:<span class="mywbr"> </span>fail:<span class="mywbr"> </span>support</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">define/<span class="mywbr"> </span>generic</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._generic-instance%2Fc%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">generic-<wbr></wbr>instance/<span class="mywbr"> </span>c</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._impersonate-generics%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">impersonate-<wbr></wbr>generics</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._chaperone-generics%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">chaperone-<wbr></wbr>generics</span></span></a></td></tr><tr><td><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._redirect-generics%29%29" class="tocsublink" data-pltdoc="x"><span class="RktSym"><span class="RktStxLink">redirect-<wbr></wbr>generics</span></span></a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="versionbox"><span class="version">6.1</span></div><div class="navsettop"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="structprops.html" title="backward to "5.3 Structure Type Properties"" data-pltdoc="x">← prev</a> <a href="structures.html" title="up to "5 Structures"" data-pltdoc="x">up</a> <a href="struct-copy.html" title="forward to "5.5 Copying and Updating Structures"" data-pltdoc="x">next →</a></span> </div><h4 x-source-module="(lib "scribblings/reference/reference.scrbl")" x-part-tag=""struct-generics"">5.4<tt> </tt><a name="(part._struct-generics)"></a><a name="(mod-path._racket/generic)"></a>Generic Interfaces</h4><p><table cellspacing="0" cellpadding="0" class="defmodule"><tr><td align="left"><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="require.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._require%29%29" class="RktStxLink" data-pltdoc="x">require</a></span><span class="stt"> </span><a href="" class="RktModLink" data-pltdoc="x"><span class="RktSym">racket/generic</span></a><span class="RktPn">)</span></td><td align="right"><span class="RpackageSpec"><span class="Smaller"> package:</span> <span class="stt">base</span></span></td></tr></table></p><p>A <a name="(tech._generic._interface)"></a><span style="font-style: italic">generic interface</span> allows per-type methods to be
associated with generic functions. Generic functions are defined
using a <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define-generics%29%29" class="RktStxLink" data-pltdoc="x">define-generics</a></span> form. Method implementations for
a structure type are defined using the <span class="RktPn">#:methods</span> keyword
(see <a href="define-struct.html" data-pltdoc="x">Defining Structure Types: <span class="RktSym"><span class="RktStxLink">struct</span></span></a>).</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><table cellspacing="0" cellpadding="0" class="RktBlk RForeground"><tr><td><span class="RktPn">(</span><a name="(form._((lib._racket/generic..rkt)._define-generics))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define-generics%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define-generics</a></span></span><span class="hspace"> </span><span class="RktVar">id</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">generics-opt</span><span class="hspace"> </span><span class="RktMeta">...</span></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">method-id</span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktVar">kw-formals*</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">generics-opt</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="specgrammar"><tr><td align="right" valign="baseline"><span class="RktVar">generics-opt</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:defaults</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVar">default-pred?</span><span class="hspace"> </span><span class="RktVar">default-impl</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:fast-defaults</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktVar">fast-pred?</span><span class="hspace"> </span><span class="RktVar">fast-impl</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:fallbacks</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">fallback-impl</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:defined-predicate</span><span class="hspace"> </span><span class="RktVar">defined-pred-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:defined-table</span><span class="hspace"> </span><span class="RktVar">defined-table-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">#:derive-property</span><span class="hspace"> </span><span class="RktVar">prop-expr</span><span class="hspace"> </span><span class="RktVar">prop-value-expr</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">kw-formals*</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktVar">arg*</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">(</span><span class="RktVar">arg*</span><span class="hspace"> </span><span class="RktMeta">...+</span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktVar">rest-id</span><span class="RktPn">)</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">rest-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td></tr><tr><td align="right" valign="baseline"><span class="RktVar">arg*</span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">=</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">arg-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktPn">[</span><span class="RktVar">arg-id</span><span class="RktPn">]</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">keyword</span><span class="hspace"> </span><span class="RktVar">arg-id</span></td></tr><tr><td align="right" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="center" valign="baseline">|</td><td align="left" valign="baseline"><span class="stt"> </span></td><td align="left" valign="baseline"><span class="RktVar">keyword</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">arg-id</span><span class="RktPn">]</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Defines the following names, plus any specified by keyword options.</div></p><ul><li><p><span class="RktSym">gen:</span><span class="RktVar">id</span> as a transformer binding for
the static information about a new generic interface;</p></li><li><p><span class="RktVar">id</span><span class="RktSym">?</span> as a predicate identifying
instances of structure types that implement this generic group; and</p></li><li><p>each <span class="RktVar">method-id</span> as a <a name="(tech._generic._method)"></a><span style="font-style: italic">generic method</span> that calls the
corresponding method on values where
<span class="RktVar">id</span><span class="RktSym">?</span> is true.
Each <span class="RktVar">method-id</span>’s <span class="RktVar">kw-formals*</span> must include a required
by-position argument that is <span class="RktSym"><a href="stxcmp.html#%28def._%28%28quote._~23~25kernel%29._free-identifier~3d~3f%29%29" class="RktValLink" data-pltdoc="x">free-identifier=?</a></span> to
<span class="RktVar">id</span>. That argument is used in the generic definition to
locate the specialization.</p></li><li><p><span class="RktVar">id</span><span class="RktSym">/c</span> as a contract combinator that
recognizes instances of structure types which implement the
<span class="RktSym">gen:</span><span class="RktVar">id</span> generic interface. The combinator
takes pairs of <span class="RktVar">method-id</span>s and contracts. The contracts
will be applied to each of the corresponding method implementations.
The <span class="RktVar">id</span><span class="RktSym">/c</span> combinator is intended to be used to
contract the range of a constructor procedure for a struct type that
implements the generic interface.</p></li></ul><p>The <span class="RktPn">#:defaults</span> option may be provided at most once.
When it is provided, each generic function
uses <span class="RktVar">default-pred?</span>s to dispatch to the given default implementations,
<span class="RktVar">default-impl</span>s, if dispatching to the generic method table fails.
The syntax of the <span class="RktVar">default-impl</span>s is the same as the methods
provided for the <span class="RktPn">#:methods</span> keyword for <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>.</p><p>The <span class="RktPn">#:fast-defaults</span> option may be provided at most once.
It works the same as <span class="RktPn">#:defaults</span>, except the <span class="RktVar">fast-pred?</span>s are
checked before dispatching to the generic method table. This option is
intended to provide a fast path for dispatching to built-in datatypes, such as
lists and vectors, that do not overlap with structures implementing
<span class="RktSym">gen:</span><span class="RktVar">id</span>.</p><p>The <span class="RktPn">#:fallbacks</span> option may be provided at most once.
When it is provided, the <span class="RktVar">fallback-impl</span>s define method implementations
that are used for any instance of the generic interface that does not supply a
specific implementation. The syntax of the <span class="RktVar">fallback-impl</span>s is the same
as the methods provided for the <span class="RktPn">#:methods</span> keyword for <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span>.</p><p>The <span class="RktPn">#:defined-predicate</span> option may be provided at most once.
When it is provided, <span class="RktVar">defined-pred-id</span> is defined as a
procedure that reports whether a specific instance of the generic interface
implements a given set of methods.
Specifically, <span class="RktPn">(</span><span class="RktVar">defined-pred-id</span><span class="stt"> </span><span class="RktSym">v</span><span class="stt"> </span><span class="RktVal">'</span><span class="RktVal">name</span><span class="stt"> </span><span class="RktMeta"><a href="stx-patterns.html#%28form._%28%28lib._racket%2Fprivate%2Fstxcase-scheme..rkt%29._......%29%29" class="RktStxLink" data-pltdoc="x">...</a></span><span class="RktPn">)</span> produces <span class="RktVal">#t</span> if
<span class="RktSym">v</span> has implementations for each method <span class="RktSym">name</span>, not counting
<span class="RktPn">#:fallbacks</span> implementations, and produces <span class="RktVal">#f</span> otherwise.
This procedure is intended for use by
higher-level APIs to adapt their behavior depending on method
availability.</p><p>The <span class="RktPn">#:defined-table</span> option may be provided at most once.
When it is provided, <span class="RktVar">defined-table-id</span> is defined as a
procedure that takes an instance of the generic interface and returns an
immutable <a href="hashtables.html#%28tech._hash._table%29" class="techoutside" data-pltdoc="x"><span class="techinside">hash table</span></a> that maps symbols corresponding to method
names to booleans representing whether or not that method is
implemented by the instance. This option is deprecated; use
<span class="RktPn">#:defined-predicate</span> instead.</p><p>The <span class="RktPn">#:derive-property</span> option may be provided any number of times.
Each time it is provided, it specifies a <a href="structprops.html#%28tech._structure._type._property%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type property</span></a> via
<span class="RktVar">prop-expr</span> and a value for the property via <span class="RktVar">prop-value-expr</span>.
All structures implementing the generic interface via <span class="RktPn">#:methods</span>
automatically implement this structure type property using the provided values.
When <span class="RktVar">prop-value-expr</span> is executed, each <span class="RktVar">method-id</span> is bound to
its specific implementation for the <a href="structures.html#%28tech._structure._type%29" class="techoutside" data-pltdoc="x"><span class="techinside">structure type</span></a>.</p><p>If a value <span class="RktSym">v</span> satisfies <span class="RktVar">id</span><span class="RktSym">?</span>, then <span class="RktSym">v</span> is
a <a name="(tech._generic._instance)"></a><span style="font-style: italic">generic instance</span> of <span class="RktSym">gen:</span><span class="RktVar">id</span>.</p><p>If a generic instance <span class="RktSym">v</span> has a corresponding implementation for some
<span class="RktVar">method-id</span> provided via <span class="RktPn">#:methods</span> in <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> or via
<span class="RktPn">#:defaults</span> or <span class="RktPn">#:fast-defaults</span> in <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define-generics%29%29" class="RktStxLink" data-pltdoc="x">define-generics</a></span>,
then <span class="RktVar">method-id</span> is an <a name="(tech._implemented._generic._method)"></a><span style="font-style: italic">implemented generic method</span> of
<span class="RktSym">v</span>.</p><p>If <span class="RktVar">method-id</span> is not an implemented generic method of a generic
instance <span class="RktSym">v</span>, and <span class="RktVar">method-id</span> has a fallback implementation that
does not raise an <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fgeneric..rkt%29._exn~3afail~3asupport%29%29" class="RktValLink" data-pltdoc="x">exn:fail:support</a></span> exception when given <span class="RktSym">v</span>,
then <span class="RktVar">method-id</span> is a <a name="(tech._supported._generic._method)"></a><span style="font-style: italic">supported generic method</span> of <span class="RktSym">v</span>.</p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>procedure</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(def._((lib._racket/generic..rkt)._raise-support-error))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fgeneric..rkt%29._raise-support-error%29%29" class="RktValDef RktValLink" data-pltdoc="x">raise-support-error</a></span></span><span class="hspace"> </span><span class="RktVar">name</span><span class="hspace"> </span><span class="RktVar">v</span><span class="RktPn">)</span><span class="hspace"> </span>→<span class="hspace"> </span><span class="RktSym">none/c</span></p></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">name</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym"><a href="symbols.html#%28def._%28%28quote._~23~25kernel%29._symbol~3f%29%29" class="RktValLink" data-pltdoc="x">symbol?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="RktVar">v</span><span class="hspace"> </span>:<span class="hspace"> </span><span class="RktSym">any/c</span></td></tr></table></blockquote></div><div class="SIntrapara">Raises an <span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fgeneric..rkt%29._exn~3afail~3asupport%29%29" class="RktValLink" data-pltdoc="x">exn:fail:support</a></span> exception for a <a href="#%28tech._generic._method%29" data-pltdoc="x">generic
method</a> called <span class="RktVar">name</span> that does not support the <a href="#%28tech._generic._instance%29" data-pltdoc="x">generic
instance</a> <span class="RktVar">v</span>.</div></p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Example:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fgeneric..rkt%29._raise-support-error%29%29" class="RktValLink" data-pltdoc="x">raise-support-error</a></span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">some-method-name</span><span class="hspace"> </span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">"arbitrary"</span><span class="hspace"> </span><span class="RktVal">"instance"</span><span class="hspace"> </span><span class="RktVal">"value"</span><span class="RktVal">)</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">some-method-name: not implemented for '("arbitrary"</span></p></td></tr><tr><td><p><span class="RktErr">"instance" "value")</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>struct</p></div></div><table cellspacing="0" cellpadding="0" class="RForeground"><tr><td><span class="RktPn">(</span><span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span></td><td><span class="hspace"> </span></td><td><a name="(def._((lib._racket/generic..rkt)._exn~3afail~3asupport~3f))"></a><a name="(def._((lib._racket/generic..rkt)._struct~3aexn~3afail~3asupport))"></a><a name="(def._((lib._racket/generic..rkt)._exn~3afail~3asupport))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28def._%28%28lib._racket%2Fgeneric..rkt%29._exn~3afail~3asupport%29%29" class="RktValDef RktValLink" data-pltdoc="x">exn:fail:support</a></span></span><span class="hspace"> </span><span class="RktSym"><a href="exns.html#%28def._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._exn~3afail%29%29" class="RktValLink" data-pltdoc="x">exn:fail</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">)</span></td></tr></table></blockquote></td></tr><tr><td><span class="hspace"> </span><span class="RktPn">#:transparent</span><span class="RktPn">)</span></td></tr></table></blockquote></div><div class="SIntrapara">Raised for <a href="#%28tech._generic._method%29" data-pltdoc="x">generic methods</a> that do not support the given
<a href="#%28tech._generic._instance%29" data-pltdoc="x">generic instance</a>.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/generic..rkt)._define/generic))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">define/generic</a></span></span><span class="hspace"> </span><span class="RktVar">local-id</span><span class="hspace"> </span><span class="RktVar">method-id</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><blockquote class="SubFlow"><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">local-id</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="stxops.html#%28def._%28%28lib._racket%2Fprivate%2Fstx..rkt%29._identifier~3f%29%29" class="RktValLink" data-pltdoc="x">identifier?</a></span></td></tr></table><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">method-id</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktSym"><a href="stxops.html#%28def._%28%28lib._racket%2Fprivate%2Fstx..rkt%29._identifier~3f%29%29" class="RktValLink" data-pltdoc="x">identifier?</a></span></td></tr></table></blockquote></td></tr></table></blockquote></div><div class="SIntrapara">When used inside the method definitions associated with the
<span class="RktPn">#:methods</span> keyword, binds <span class="RktVar">local-id</span> to the generic for
<span class="RktVar">method-id</span>. This form is useful for method specializations to
use generic methods (as opposed to the local specialization) on other
values.</div></p><p>Using the <span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29" class="RktStxLink" data-pltdoc="x">define/generic</a></span> form outside a <span class="RktPn">#:methods</span>
specification in <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._struct%29%29" class="RktStxLink" data-pltdoc="x">struct</a></span> (or <span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span>) is an
syntax error.</p><p><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><p>Examples:</p></td></tr><tr><td><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define-generics%29%29" class="RktStxLink" data-pltdoc="x">define-generics</a></span><span class="hspace"> </span><span class="RktSym">printable</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktSym">printable</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-port-print</span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktSym">printable</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktSym">printable</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktSym">width</span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">height</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:defaults</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktPn">[</span><span class="RktSym"><a href="strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29" class="RktValLink" data-pltdoc="x">string?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29" class="RktStxLink" data-pltdoc="x">define/generic</a></span><span class="hspace"> </span><span class="RktSym">super-print</span><span class="hspace"> </span><span class="RktSym">gen-print</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktSym">s</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._fprintf%29%29" class="RktValLink" data-pltdoc="x">fprintf</a></span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktVal">"String: ~a"</span><span class="hspace"> </span><span class="RktSym">s</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-port-print</span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktSym">s</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">super-print</span><span class="hspace"> </span><span class="RktSym">s</span><span class="hspace"> </span><span class="RktSym">port</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktSym">s</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktSym">w</span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">h</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._fprintf%29%29" class="RktValLink" data-pltdoc="x">fprintf</a></span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktVal">"String (~ax~a): ~a"</span><span class="hspace"> </span><span class="RktSym">w</span><span class="hspace"> </span><span class="RktSym">h</span><span class="hspace"> </span><span class="RktSym">s</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span><span class="hspace"> </span><span class="RktSym">num</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:methods</span><span class="hspace"> </span><span class="RktSym">gen:printable</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29" class="RktStxLink" data-pltdoc="x">define/generic</a></span><span class="hspace"> </span><span class="RktSym">super-print</span><span class="hspace"> </span><span class="RktSym">gen-print</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._fprintf%29%29" class="RktValLink" data-pltdoc="x">fprintf</a></span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktVal">"Num: ~a"</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">num-v</span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-port-print</span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">super-print</span><span class="hspace"> </span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktSym">port</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktSym">n</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktSym">w</span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">h</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._fprintf%29%29" class="RktValLink" data-pltdoc="x">fprintf</a></span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktVal">"Num (~ax~a): ~a"</span><span class="hspace"> </span><span class="RktSym">w</span><span class="hspace"> </span><span class="RktSym">h</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">num-v</span><span class="hspace"> </span><span class="RktSym">n</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="define-struct.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define-struct%29%29" class="RktStxLink" data-pltdoc="x">define-struct</a></span><span class="hspace"> </span><span class="RktSym">bool</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">v</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:methods</span><span class="hspace"> </span><span class="RktSym">gen:printable</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktPn">(</span><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._define%2Fgeneric%29%29" class="RktStxLink" data-pltdoc="x">define/generic</a></span><span class="hspace"> </span><span class="RktSym">super-print</span><span class="hspace"> </span><span class="RktSym">gen-print</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._fprintf%29%29" class="RktValLink" data-pltdoc="x">fprintf</a></span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktVal">"Bool: ~a"</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">bool-v</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"Yes"</span><span class="hspace"> </span><span class="RktVal">"No"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-port-print</span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">super-print</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktSym">port</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktSym">b</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktSym">w</span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">h</span><span class="hspace"> </span><span class="RktVal">0</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="Writing.html#%28def._%28%28quote._~23~25kernel%29._fprintf%29%29" class="RktValLink" data-pltdoc="x">fprintf</a></span><span class="hspace"> </span><span class="RktSym">port</span><span class="hspace"> </span><span class="RktVal">"Bool (~ax~a): ~a"</span><span class="hspace"> </span><span class="RktSym">w</span><span class="hspace"> </span><span class="RktSym">h</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="if.html#%28form._%28%28quote._~23~25kernel%29._if%29%29" class="RktStxLink" data-pltdoc="x">if</a></span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">bool-v</span><span class="hspace"> </span><span class="RktSym">b</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktVal">"Yes"</span><span class="hspace"> </span><span class="RktVal">"No"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-num</span><span class="hspace"> </span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">Num: 10</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-port-print</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">Num: 10</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktSym">x</span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktVal">100</span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktVal">90</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">Num (100x90): 10</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktVal">"Strings are printable too!"</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">String: Strings are printable too!</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-bool</span><span class="hspace"> </span><span class="RktVal">#t</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">Bool: Yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-port-print</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._current-output-port%29%29" class="RktValLink" data-pltdoc="x">current-output-port</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym">y</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">Bool: Yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktSym">y</span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktVal">100</span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktVal">90</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktOut">Bool (100x90): Yes</span></p></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">define/contract</span><span class="hspace"> </span><span class="RktSym">make-num-contracted</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><span class="nobreak">-></span></span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._number~3f%29%29" class="RktValLink" data-pltdoc="x">number?</a></span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">printable/c</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">gen-print</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><span class="nobreak">-></span>*</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">printable?</span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._output-port~3f%29%29" class="RktValLink" data-pltdoc="x">output-port?</a></span><span class="RktPn">)</span><span class="hspace"> </span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">gen-port-print</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><span class="nobreak">-></span></span><span class="hspace"> </span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._output-port~3f%29%29" class="RktValLink" data-pltdoc="x">output-port?</a></span><span class="hspace"> </span><span class="RktSym">printable?</span><span class="hspace"> </span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><span class="nobreak">-></span>*</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">printable?</span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym"><a href="port-ops.html#%28def._%28%28quote._~23~25kernel%29._output-port~3f%29%29" class="RktValLink" data-pltdoc="x">output-port?</a></span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktSym"><a href="number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-nonnegative-integer~3f%29%29" class="RktValLink" data-pltdoc="x">exact-nonnegative-integer?</a></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym"><a href="void.html#%28def._%28%28quote._~23~25kernel%29._void~3f%29%29" class="RktValLink" data-pltdoc="x">void?</a></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace"> </span><span class="hspace"> </span><span class="RktSym">make-num</span><span class="RktPn">)</span></td></tr></table></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym"><a href="define.html#%28form._%28%28lib._racket%2Fprivate%2Fbase..rkt%29._define%29%29" class="RktStxLink" data-pltdoc="x">define</a></span><span class="hspace"> </span><span class="RktSym">z</span><span class="hspace"> </span><span class="RktPn">(</span><span class="RktSym">make-num-contracted</span><span class="hspace"> </span><span class="RktVal">10</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><table cellspacing="0" cellpadding="0"><tr><td></td></tr></table></td></tr><tr><td><span class="stt">> </span><span class="RktPn">(</span><span class="RktSym">gen-print*</span><span class="hspace"> </span><span class="RktSym">z</span><span class="hspace"> </span><span class="RktPn">#:width</span><span class="hspace"> </span><span class="RktVal">"not a number"</span><span class="hspace"> </span><span class="RktPn">#:height</span><span class="hspace"> </span><span class="RktVal">5</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">make-num-contracted: contract violation</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">expected: exact-nonnegative-integer?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">given: "not a number"</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">in: the #:width argument of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">method gen-print*</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">the range of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(-></span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">number?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(printable/c</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(gen-print</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(->* (printable?) (output-port?) void?))</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(gen-port-print</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(-> output-port? printable? void?))</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(gen-print*</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(->*</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(printable?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">#:width</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">exact-nonnegative-integer?)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(output-port?</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">#:height</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">exact-nonnegative-integer?)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">void?))))</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">contract from: </span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">(definition make-num-contracted)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">blaming: top-level</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace"> </span><span class="RktErr">at: eval:15.0</span></p></td></tr></table></blockquote></td></tr></table></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/generic..rkt)._generic-instance/c))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._generic-instance%2Fc%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">generic-instance/c</a></span></span><span class="hspace"> </span><span class="RktVar">gen-id</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">method-id</span><span class="hspace"> </span><span class="RktVar">method-ctc</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">method-ctc</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktSym">contract?</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Creates a contract that recognizes structures that implement the <a href="#%28tech._generic._interface%29" class="techoutside" data-pltdoc="x"><span class="techinside">generic
interface</span></a> <span class="RktVar">gen-id</span>, and constrains their implementations of the
specified <span class="RktVar">method-id</span>s with the corresponding <span class="RktVar">method-ctc</span>s.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/generic..rkt)._impersonate-generics))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._impersonate-generics%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">impersonate-generics</a></span></span><span class="hspace"> </span><span class="RktVar">gen-id</span><span class="hspace"> </span><span class="RktVar">val-expr</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">method-id</span><span class="hspace"> </span><span class="RktVar">method-proc</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">method-proc</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktPn">(</span><span class="RktSym">any/c</span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><span class="nobreak">-></span></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym">any/c</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Creates an <a href="chaperones.html#%28tech._impersonator%29" class="techoutside" data-pltdoc="x"><span class="techinside">impersonator</span></a> of <span class="RktVar">val-expr</span>, which must be a structure
that implements the <a href="#%28tech._generic._interface%29" class="techoutside" data-pltdoc="x"><span class="techinside">generic interface</span></a> <span class="RktVar">gen-id</span>. The impersonator
applies the specified <span class="RktVar">method-proc</span>s to the structure’s implementation
of the corresponding <span class="RktVar">method-id</span>s, and replaces the method
implementation with the result.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/generic..rkt)._chaperone-generics))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._chaperone-generics%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">chaperone-generics</a></span></span><span class="hspace"> </span><span class="RktVar">gen-id</span><span class="hspace"> </span><span class="RktVar">val-expr</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">method-id</span><span class="hspace"> </span><span class="RktVar">method-proc</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">method-proc</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktPn">(</span><span class="RktSym">any/c</span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><span class="nobreak">-></span></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym">any/c</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Creates a <a href="chaperones.html#%28tech._chaperone%29" class="techoutside" data-pltdoc="x"><span class="techinside">chaperone</span></a> of <span class="RktVar">val-expr</span>, which must be a structure
that implements the <a href="#%28tech._generic._interface%29" class="techoutside" data-pltdoc="x"><span class="techinside">generic interface</span></a> <span class="RktVar">gen-id</span>. The chaperone
applies the specified <span class="RktVar">method-proc</span>s to the structure’s implementation
of the corresponding <span class="RktVar">method-id</span>s, and replaces the method
implementation with the result, which must be a chaperone of the original.</div></p><p><div class="SIntrapara"><blockquote class="SVInsetFlow"><table cellspacing="0" cellpadding="0" class="boxed RBoxed"><tr><td><blockquote class="SubFlow"><div class="RBackgroundLabel SIEHidden"><div class="RBackgroundLabelInner"><p>syntax</p></div></div><p class="RForeground"><span class="RktPn">(</span><a name="(form._((lib._racket/generic..rkt)._redirect-generics))"></a><span title="Provided from: racket/generic | Package: base"><span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._redirect-generics%29%29" class="RktStxDef RktStxLink" data-pltdoc="x">redirect-generics</a></span></span><span class="hspace"> </span><span class="RktVar">mode</span><span class="hspace"> </span><span class="RktVar">gen-id</span><span class="hspace"> </span><span class="RktVar">val-expr</span><span class="hspace"> </span><span class="RktPn">[</span><span class="RktVar">method-id</span><span class="hspace"> </span><span class="RktVar">method-proc</span><span class="RktPn">]</span><span class="hspace"> </span><span class="RktMeta">...</span><span class="RktPn">)</span></p></blockquote></td></tr><tr><td><span class="stt"> </span></td></tr><tr><td><table cellspacing="0" cellpadding="0" class="argcontract"><tr><td><span class="hspace"> </span></td><td><span class="RktVar">method-proc</span></td><td><span class="hspace"> </span></td><td>:</td><td><span class="hspace"> </span></td><td><span class="RktPn">(</span><span class="RktSym">any/c</span><span class="hspace"> </span><span class="RktPn">. </span><span class="RktSym"><span class="nobreak">-></span></span><span class="RktPn"> .</span><span class="hspace"> </span><span class="RktSym">any/c</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote></div><div class="SIntrapara">Creates an <a href="chaperones.html#%28tech._impersonator%29" class="techoutside" data-pltdoc="x"><span class="techinside">impersonator</span></a> of <span class="RktVar">val-expr</span>, like
<span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._impersonate-generics%29%29" class="RktStxLink" data-pltdoc="x">impersonate-generics</a></span>, if <span class="RktVar">mode</span> evaluates to <span class="RktVal">#f</span>.
Creates a <a href="chaperones.html#%28tech._chaperone%29" class="techoutside" data-pltdoc="x"><span class="techinside">chaperone</span></a> of <span class="RktVar">val-expr</span>, like
<span class="RktSym"><a href="#%28form._%28%28lib._racket%2Fgeneric..rkt%29._chaperone-generics%29%29" class="RktStxLink" data-pltdoc="x">chaperone-generics</a></span>, otherwise.</div></p><div class="navsetbottom"><span class="navleft"><form class="searchform"><input class="searchbox" style="color: #888;" type="text" value="...search manuals..." title="Enter a search string to search the manuals" onkeypress="return DoSearchKey(event, this, "6.1", "../");" onfocus="this.style.color="black"; this.style.textAlign="left"; if (this.value == "...search manuals...") this.value="";" onblur="if (this.value.match(/^ *$/)) { this.style.color="#888"; this.style.textAlign="center"; this.value="...search manuals..."; }"/></form> <a href="../index.html" title="up to the documentation top" data-pltdoc="x" onclick="return GotoPLTRoot("6.1");">top</a></span><span class="navright"> <a href="structprops.html" title="backward to "5.3 Structure Type Properties"" data-pltdoc="x">← prev</a> <a href="structures.html" title="up to "5 Structures"" data-pltdoc="x">up</a> <a href="struct-copy.html" title="forward to "5.5 Copying and Updating Structures"" data-pltdoc="x">next →</a></span> </div></div></div><div id="contextindicator"> </div></body></html>
|