| <!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.3.4.b.html" rel="next">§2.3.4.(b) Definite ambiguity >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.3.html" rel="section">§2.3 Lifting</a> > <a class="nav" href="s2.3.4.html" rel="section">§2.3.4 Binding ambiguities</a></div> |
| <div class="subsect depth4" id="s2.3.4.a"> |
| <h4 class="subsect">§2.3.4.(a) <span class="title">Potential ambiguity</span><a class="img" href="s2.3.4.a.html" |
| title="PermaLink to (a) Potential ambiguity"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>A <strong>potential ambiguity</strong> is given, |
| if two role classes <code>R1</code> and <code>R2</code> |
| exist such that |
| |
| </p> |
| <ul> |
| <li><code>R1</code> and <code>R2</code> are played by the |
| same base class <code>B</code>, and |
| </li> |
| <li><code>R1</code> and <code>R2</code> have a common |
| super role <code>R0</code>, |
| which is also bound to a base class <code>B0</code>, and |
| </li> |
| <li>neither role class <code>R1</code> nor |
| <code>R2</code> is a (indirect) sub-class of the other. |
| </li> |
| </ul> |
| <div class="note"> |
| <h5>Note:</h5> |
| According to <a href="s2.1.c.html" title="§2.1.(c) Covariant refinement" |
| class="sect">§2.1.(c)</a>, if <code>B</code> is distinct from <code>B0</code> |
| it has to be a sub-class of <code>B0</code>. |
| |
| </div> |
| <div class="note"> |
| <h5>Effect:</h5> |
| In this case the compiler issues a warning, stating that the <code>B</code><em> may not be liftable,</em> because both role classes <code>R1</code> |
| and <code>R2</code> are candidates and there is no reason to prefer one over the other. |
| <br /><strong>If no potential ambiguity is detected, lifting will always be unambiguous.</strong></div> |
| <p>In the above situation, trying to lift an instance of type <code>B</code> to the role type |
| <code>R0</code> is an <strong>illegal lifting request</strong>. If <code>R0</code> is bound |
| to the same base class <code>B</code> as its sub-roles <code>R1</code> and <code>R2</code> are, |
| role <code>R0</code> is <strong>unliftable</strong>, meaning that no instance of <code>R0</code> |
| can ever by obtained by lifting. |
| |
| </p> |
| <h5 class="listing">Example code (Potential Ambiguity):</h5> |
| <div class="listing example frame"> |
| <table class="listing"> |
| <tr class="line odd"> |
| <td class="ln">1</td> |
| <td><pre><b>team</b> <b>class</b> MyTeam {</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">2</td> |
| <td><pre> <b>public</b> <b>class</b> SuperRole <b>playedBy</b> MyBase {...}</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">3</td> |
| <td><pre> <b>public</b> <b>class</b> SubRoleA <b>extends</b> SuperRole {...}</pre></td> |
| </tr> |
| <tr class="line even"> |
| <td class="ln">4</td> |
| <td><pre> <b>public</b> <b>class</b> SubRoleB <b>extends</b> SuperRole {...}</pre></td> |
| </tr> |
| <tr class="line odd"> |
| <td class="ln">5</td> |
| <td><pre>}</pre></td> |
| </tr> |
| </table> |
| </div> |
| </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.3.4.b.html" rel="next">§2.3.4.(b) Definite ambiguity >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s2.html" rel="section">§2 Role Binding</a> > <a class="nav" href="s2.3.html" rel="section">§2.3 Lifting</a> > <a class="nav" href="s2.3.4.html" rel="section">§2.3.4 Binding ambiguities</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> |