blob: af225c84ef563480377e7392fe3a9e42dc903308 [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.1</title>
</head>
<body class="otdt">
<div id="content">
<table class="nav">
<tr>
<td class="back"><a id="top"></a><a href="s2.4.2.b.html" rel="prev">&lt;&lt;&nbsp;&sect;2.4.2.(b)&nbsp;Bound roles</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.4.html" rel="section">&sect;2.4&nbsp;Explicit role creation</a>&nbsp;&gt;&nbsp;<a class="nav" href="s2.4.2.html" rel="section">&sect;2.4.2&nbsp;Role creation via a regular constructor</a></div>
<div class="subsect depth4" id="s2.4.2.c">
<h4 class="subsect">&sect;2.4.2.(c)&nbsp;<span class="title">Super-call for bound roles</span><a class="img" href="s2.4.2.c.html"
title="PermaLink to (c)&nbsp;Super-call for bound roles"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h4>
<p>Instead of or prior to calling <code>base(..)</code> a constructor of a bound role explicitly or implicitly calls a super constructor.
Which constructor is applicable depends on the super role and its <code>playedBy</code> clause.
</p>
<ul>
<li>If the super role is bound to the same base class as the current role is,
<ul>
<li>not writing a super-call causes the lifting constructor of the super role to be invoked.</li>
<li>explicitly calling a super constructor requires the super constructor to <i>either</i><ol>
<li>create a role instance using a base constructor call (directly or indirectly), <i>or</i></li>
<li>be a lifting constructor receiving a base instance, which the current role must provide as the argument.</li>
</ol>
</li>
</ul>
</li>
<li>If the super role is bound but the current role refines the <code>playedBy</code>
relationship (cf. <a href="s2.1.c.html" title="&sect;2.1.(c)&nbsp;Covariant refinement"
class="sect">&sect;2.1.(c)</a>),
<ul>
<li>a lifting constructor must be called explicitly passing a base object as the argument.</li>
</ul>
</li>
<li>If the role has an explicit or implicit super role which is unbound the constructor may optionally
call a super constructor (using <code>super(..)</code> or <code>tsuper(..)</code>) prior to calling
<code>base(..)</code>. Otherwise the default constructor is implicitly invoked.
</li>
</ul>
<p>When invoking a lifting constructor of a super role the base object can optionally be obtained by using a base constructor
call as an expression:
</p>
<div class="listing plain"><pre>super(base(<i>&lt;args&gt;</i>));</pre></div>
</div>
<table class="nav">
<tr>
<td class="back"><a href="s2.4.2.b.html" rel="prev">&lt;&lt;&nbsp;&sect;2.4.2.(b)&nbsp;Bound roles</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.4.html" rel="section">&sect;2.4&nbsp;Explicit role creation</a>&nbsp;&gt;&nbsp;<a class="nav" href="s2.4.2.html" rel="section">&sect;2.4.2&nbsp;Role creation via a regular constructor</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.1 &mdash; last modified: 2013-05-28
</div>
</body>
</html>