Constrained genericity: Difference between revisions

m
→‎{{header|TXR}}: Unbalanced code tags in bulleted section.
(→‎{{header|TXR}}: New section.)
m (→‎{{header|TXR}}: Unbalanced code tags in bulleted section.)
Line 1,617:
In the interactive session, we:
 
* verify that <code>define-food-box</code> cannot be used with a type argument that isn't derived from <code>edible</code>
* define the struct type <code>edible</code> and then one derived from it called <code>perishable</code>.
* use <code>define-food-box</code> to define a box called <code>fridge</code> which holds <code>perishable</code>. This works because <code>perishable</code> is <code>edible</code>
* create an instance of <code>fridge</code> and show that its <code>set-food</code> method doesn't take an integer, or an <code>edible</code>; only a <code>perishable</code>.
 
<pre>$ txr -i generic.tl
543

edits