| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "../xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| <link rel="stylesheet" type="text/css" href="../css/ot.css" /> |
| <link rel="stylesheet" type="text/css" href="../css/otjld.css" /> |
| <title>OT/J Language Definition v1.3</title> |
| </head> |
| <body class="otdt"> |
| <div id="content"> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a id="top"></a><a href="s2.7.c.html" rel="prev"><< §2.7.(c) Layering</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.7.html" rel="section">§2.7 Advanced structures</a></div> |
| <div class="subsect depth3" id="s2.7.d"> |
| <h4 class="subsect">§2.7.(d) <span class="title">Implicit playedBy specialization</span><a class="img" href="s2.7.d.html" |
| title="PermaLink to (d) Implicit playedBy specialization"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>According to <a href="s2.1.d.html" title="§2.1.(d) No-variance" class="sect">§2.1.(d)</a> an implicit sub-role may <em>implicitly</em> specialize an existing <code>playedBy</code> relation. |
| This requires the base class to be specified relative to some implicit (<code>OuterTeam.this</code>) or explicit (<code>OuterTeam.base</code>) team anchor. |
| Specializing that team anchor automatically specializes the playedBy declaration, too. |
| This rule never requires any action from a programmer but only explains the interpretation of a playedBy declaration in |
| complex situations. |
| |
| </p> |
| <h5>Two advanced examples demonstrating the above are:</h5> |
| <table border="0"> |
| <colgroup span="1"> |
| <col align="left" span="1" /> |
| <col align="left" span="1" /> |
| </colgroup> |
| <tr> |
| <td rowspan="1" colspan="1"> |
| <ul> |
| <li>If a role <code>TOuter1.T.R</code> of a <strong>nested team </strong><code>TOuter1.T</code> is played by |
| another role of the outer enclosing team <code>TOuter1.B</code>, subclassing the outer team <code>TOuter1</code> to <code>TOuter2</code> |
| will produce a new role <code>TOuter2.T.R</code> which is automatically played by <code>TOuter2.B</code>, |
| an implicit sub class of the original base class <code>TOuter1.B</code>. |
| </li> |
| </ul> |
| </td> |
| <td rowspan="1" colspan="1"><img src="../images/implicitly_overriding_playedby.png" |
| alt="Implicitly overriding playedBy" /></td> |
| </tr> |
| <tr> |
| <td rowspan="1" colspan="1"> |
| <ul> |
| <li>Consider the case where a <strong>nested </strong><code>T1</code> as a role of <code>TOuter</code> is <strong>stacked</strong> |
| on a base team <code>TB1</code>. Also, <code>T1</code> is a <strong>layered team</strong> over <code>TB1</code> |
| because its role <code>R</code> adapts role <code>TB1.B</code>. |
| <br /> |
| In this situation the playedBy relation of role <code>TOuter.T1.R</code> is given by a base-anchored type <code>B<@T1.base></code>. |
| If furthermore <code>TOuter.T1</code> is subclassed to <code>TOuter.T2</code> which covariantly refines the inherited |
| playedBy declaration to <code>TB2</code>, then <code>TOuter.T2.R</code> will automatically refine the inherited playedBy relation |
| to <code>TB2.B</code> to follow the new interpretation of the <code>base</code> anchor. |
| </li> |
| </ul> |
| </td> |
| <td rowspan="1" colspan="1"><img src="../images/implicitly_overriding_playedby_base.png" |
| alt="Implicitly overriding playedBy base" /></td> |
| </tr> |
| </table> |
| </div> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a href="s2.7.c.html" rel="prev"><< §2.7.(c) Layering</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.7.html" rel="section">§2.7 Advanced structures</a></div> |
| </div> |
| <div id="footer"> |
| <hr /><a class="w3c img" href="http://jigsaw.w3.org/css-validator/check/referer" |
| shape="rect"><img src="../images/valid-css2-blue.png" alt="Valid CSS!" height="31" width="88" /></a><a class="w3c img" href="http://validator.w3.org/check?uri=referer" shape="rect"><img src="../images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" |
| width="88" /></a><address>© Stephan Herrmann, Christine Hundt, Marco Mosconi</address> |
| OT/J version 1.3 — last modified: 2010-05-18 |
| </div> |
| </body> |
| </html> |