| <!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="s9.2.html" rel="next">§9.2 Using classes with value parameters >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s9.html" rel="section">§9 Value Dependent Classes</a></div> |
| <div class="sect depth2" id="s9.1"> |
| <h2 class="sect">§9.1 Defining classes with value parameters<a class="img" href="s9.1.html" |
| title="PermaLink to §9.1 Defining classes with value parameters"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h2> |
| <div class="syntaxlink"><a href="sA.html#sA.9.1" title="§A.9.1 TypeParameter" class="syntax">→ Syntax §A.9.1</a></div> |
| <div class="subsect depth3" id="s9.1.a"> |
| <h4 class="subsect">(a) <span class="title">Value parameter declaration</span><a class="img" href="s9.1.a.html" |
| title="PermaLink to (a) Value parameter declaration"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>Within the angle brackets that mark the parameters of a generic class also value parameters |
| can be declared. In contrast to a type parameter, a value parameter is denoted as a pair |
| of two identifiers: a type and a free name, e.g., |
| |
| </p> |
| <div class="listing plain"><pre><b>class</b> MyClass<em><YourType aName></em> { ...</pre></div> |
| <p>Note that value parameters are valid for classes only, not for interfaces. |
| |
| </p> |
| </div> |
| <div class="subsect depth3" id="s9.1.b"> |
| <h4 class="subsect">(b) <span class="title">Value parameter application</span><a class="img" href="s9.1.b.html" |
| title="PermaLink to (b) Value parameter application"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>Within the given class (<code>MyClass</code>) the parameter name (<code>aName</code>) can be used |
| like a final field of the given type (<code>YourType</code>). In contrast to regular final fields |
| the assignment to this name occurs even before the constructor is executed. |
| |
| </p> |
| </div> |
| <div class="subsect depth3" id="s9.1.c"> |
| <h4 class="subsect">(c) <span class="title">Role types as dependent types</span><a class="img" href="s9.1.c.html" |
| title="PermaLink to (c) Role types as dependent types"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>Any role type can be interpreted as a value dependent type, however, in the declaration |
| of a role type the value parameter remains implicit: it is identical to the enclosing team instance. |
| |
| </p> |
| </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="s9.2.html" rel="next">§9.2 Using classes with value parameters >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s9.html" rel="section">§9 Value Dependent Classes</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-06-08 |
| </div> |
| </body> |
| </html> |