blob: ef3fb519220b08dd26b50e6efc7e31c2b835a739 [file] [log] [blame]
<!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">&lt;&lt;&nbsp;&sect;2.7.(c)&nbsp;Layering</a></td>
<td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
<td class="next"></td>
</tr>
</table>
<div class="breadcrumb"><a class="nav" href="s2.html" rel="section">&sect;2&nbsp;Role Binding</a>&nbsp;&gt;&nbsp;<a class="nav" href="s2.7.html" rel="section">&sect;2.7&nbsp;Advanced structures</a></div>
<div class="subsect depth3" id="s2.7.d">
<h4 class="subsect">&sect;2.7.(d)&nbsp;<span class="title">Implicit playedBy specialization</span><a class="img" href="s2.7.d.html"
title="PermaLink to (d)&nbsp;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="&sect;2.1.(d)&nbsp;No-variance" class="sect">&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&lt;@T1.base&gt;</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">&lt;&lt;&nbsp;&sect;2.7.(c)&nbsp;Layering</a></td>
<td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
<td class="next"></td>
</tr>
</table>
<div class="breadcrumb"><a class="nav" href="s2.html" rel="section">&sect;2&nbsp;Role Binding</a>&nbsp;&gt;&nbsp;<a class="nav" href="s2.7.html" rel="section">&sect;2.7&nbsp;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>&copy; Stephan Herrmann, Christine Hundt, Marco Mosconi</address>
OT/J version 1.3 &mdash; last modified: 2011-05-15
</div>
</body>
</html>