| <!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></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"><a href="s2.6.b.html" rel="next">§2.6.(b) Explicit base object creation >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.6.html" rel="section">§2.6 Explicit base references</a></div> |
| <div class="subsect depth3" id="s2.6.a"> |
| <h4 class="subsect">§2.6.(a) <span class="title">Externalized roles of a base team</span><a class="img" href="s2.6.a.html" |
| title="PermaLink to (a) Externalized roles of a base team"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>If the base class of a role <code>T1.R1</code> is again a team |
| <code>T2</code>, roles of that team <code>T2</code> can be |
| externalized (see <a href="s1.2.2.html" title="§1.2.2 Externalized roles" class="sect">§1.2.2</a>) |
| using <code>base</code> as their type anchor. Given that |
| <code>R2</code> is a role of <code>T2</code>, one could write: |
| |
| </p> |
| <div class="listing example frame"> |
| <table class="listing"> |
| <tr class="line odd"> |
| <td class="ln">1</td> |
| <td><pre><b>public</b> <b>team</b> <b>class</b> T1 {</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">2</td> |
| <td><pre> <b>protected</b> <b>class</b> R1 <em><b>playedBy</b> T2</em> {</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">3</td> |
| <td><pre> <b>protected</b> <em>R2<@base></em> aRoleOfMyBase;</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">4</td> |
| <td><pre> }</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">5</td> |
| <td><pre>}</pre></td> |
| </tr> |
| </table> |
| </div> |
| <p>This syntax is only legal within the body of the role <code>T1.R1</code> which is bound |
| to the team <code>T2</code> containing role <code>R2</code>. |
| A static type prefix can be used to disambiguate a base anchor, so the explicit variant |
| of the above type would be <code>R2<@<strong>R1</strong>.base></code>. |
| <br /> |
| It is not legal to use a type anchor containing <code>base</code> as an element in a path |
| of references like <code><@base.<span class="error">field</span>></code> |
| or <code><@<span class="error">field</span>.base></code>. |
| |
| </p> |
| </div> |
| <table class="nav"> |
| <tr> |
| <td class="back"></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"><a href="s2.6.b.html" rel="next">§2.6.(b) Explicit base object creation >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.6.html" rel="section">§2.6 Explicit base references</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: 2011-05-12 |
| </div> |
| </body> |
| </html> |