blob: 24919d9495521c8bed1214dc3a437410f6ec9143 [file] [log] [blame]
Stephan Herrmann01664412010-04-01 20:28:43 +00001<!DOCTYPE html
2 PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "../xhtml1-strict.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4 <head>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
Stephan Herrmann01664412010-04-01 20:28:43 +00006 <link rel="stylesheet" type="text/css" href="../css/ot.css" />
7 <link rel="stylesheet" type="text/css" href="../css/otjld.css" />
8 <title>OT/J Language Definition v1.3</title>
9 </head>
10 <body class="otdt">
11 <div id="content">
12 <table class="nav">
13 <tr>
14 <td class="back"><a id="top"></a></td>
15 <td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
16 <td class="next"><a href="s2.3.4.b.html" rel="next">&sect;2.3.4.(b)&nbsp;Definite ambiguity&nbsp;&gt;&gt;</a></td>
17 </tr>
18 </table>
19 <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.3.html" rel="section">&sect;2.3&nbsp;Lifting</a>&nbsp;&gt;&nbsp;<a class="nav" href="s2.3.4.html" rel="section">&sect;2.3.4&nbsp;Binding ambiguities</a></div>
20 <div class="subsect depth4" id="s2.3.4.a">
Stephan Herrmann109893e2010-05-18 22:02:53 +000021 <h4 class="subsect">&sect;2.3.4.(a)&nbsp;<span class="title">Potential ambiguity</span><a class="img" href="s2.3.4.a.html"
22 title="PermaLink to (a)&nbsp;Potential ambiguity"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
23 alt="" /></a></h4>
Stephan Herrmann01664412010-04-01 20:28:43 +000024 <p>A <strong>potential ambiguity</strong> is given,
25 if two role classes <code>R1</code> and <code>R2</code>
26 exist such that
27
28 </p>
29 <ul>
30 <li><code>R1</code> and <code>R2</code> are played by the
31 same base class <code>B</code>, and
32 </li>
33 <li><code>R1</code> and <code>R2</code> have a common
34 super role <code>R0</code>,
35 which is also bound to a base class <code>B0</code>, and
36 </li>
37 <li>neither role class <code>R1</code> nor
38 <code>R2</code> is a (indirect) sub-class of the other.
39 </li>
40 </ul>
41 <div class="note">
42 <h5>Note:</h5>
43 According to <a href="s2.1.c.html" title="&sect;2.1.(c)&nbsp;Covariant refinement"
44 class="sect">&sect;2.1.(c)</a>, if <code>B</code> is distinct from <code>B0</code>
45 it has to be a sub-class of <code>B0</code>.
46
47 </div>
48 <div class="note">
49 <h5>Effect:</h5>
50 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>
51 and <code>R2</code> are candidates and there is no reason to prefer one over the other.
52 <br /><strong>If no potential ambiguity is detected, lifting will always be unambiguous.</strong></div>
53 <p>In the above situation, trying to lift an instance of type <code>B</code> to the role type
54 <code>R0</code> is an <strong>illegal lifting request</strong>. If <code>R0</code> is bound
55 to the same base class <code>B</code> as its sub-roles <code>R1</code> and <code>R2</code> are,
56 role <code>R0</code> is <strong>unliftable</strong>, meaning that no instance of <code>R0</code>
57 can ever by obtained by lifting.
58
59 </p>
60 <h5 class="listing">Example code (Potential Ambiguity):</h5>
61 <div class="listing example frame">
62 <table class="listing">
63 <tr class="line odd">
64 <td class="ln">1</td>
65 <td><pre><b>team</b> <b>class</b> MyTeam {</pre></td>
66 </tr>
67 <tr class="line even">
68 <td class="ln">2</td>
69 <td><pre> <b>public</b> <b>class</b> SuperRole <b>playedBy</b> MyBase {...}</pre></td>
70 </tr>
71 <tr class="line odd">
72 <td class="ln">3</td>
73 <td><pre> <b>public</b> <b>class</b> SubRoleA <b>extends</b> SuperRole {...}</pre></td>
74 </tr>
75 <tr class="line even">
76 <td class="ln">4</td>
77 <td><pre> <b>public</b> <b>class</b> SubRoleB <b>extends</b> SuperRole {...}</pre></td>
78 </tr>
79 <tr class="line odd">
80 <td class="ln">5</td>
81 <td><pre>}</pre></td>
82 </tr>
83 </table>
84 </div>
85 </div>
86 <table class="nav">
87 <tr>
88 <td class="back"></td>
89 <td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
90 <td class="next"><a href="s2.3.4.b.html" rel="next">&sect;2.3.4.(b)&nbsp;Definite ambiguity&nbsp;&gt;&gt;</a></td>
91 </tr>
92 </table>
93 <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.3.html" rel="section">&sect;2.3&nbsp;Lifting</a>&nbsp;&gt;&nbsp;<a class="nav" href="s2.3.4.html" rel="section">&sect;2.3.4&nbsp;Binding ambiguities</a></div>
94 </div>
95 <div id="footer">
Stephan Herrmann109893e2010-05-18 22:02:53 +000096 <hr /><a class="w3c img" href="http://jigsaw.w3.org/css-validator/check/referer"
97 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"
98 width="88" /></a><address>&copy; Stephan Herrmann, Christine Hundt, Marco Mosconi</address>
Stephan Herrmann8f0fa312010-06-08 18:24:55 +000099 OT/J version 1.3 &mdash; last modified: 2010-06-08
Stephan Herrmann01664412010-04-01 20:28:43 +0000100 </div>
101 </body>
102</html>