]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | <head> | |
3 | <!-- Generated by the Spirit (http://spirit.sf.net) QuickDoc --> | |
4 | <title>Values</title> | |
5 | <link rel="stylesheet" href="theme/style.css" type="text/css"> | |
6 | <link rel="prev" href="arguments.html"> | |
7 | <link rel="next" href="variables.html"> | |
8 | </head> | |
9 | <body> | |
10 | <table width="100%" height="48" border="0" background="theme/bkd2.gif" cellspacing="2"> | |
11 | <tr> | |
12 | <td width="10"> | |
13 | </td> | |
14 | <td width="85%"> | |
15 | <font size="6" face="Verdana, Arial, Helvetica, sans-serif"><b>Values</b></font> | |
16 | </td> | |
17 | <td width="112"><a href="http://spirit.sf.net"><img src="theme/spirit.gif" align="right" border="0"></a></td> | |
18 | </tr> | |
19 | </table> | |
20 | <br> | |
21 | <table border="0"> | |
22 | <tr> | |
23 | <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td> | |
24 | <td width="30"><a href="arguments.html"><img src="theme/l_arr.gif" border="0"></a></td> | |
25 | <td width="20"><a href="variables.html"><img src="theme/r_arr.gif" border="0"></a></td> | |
26 | </tr> | |
27 | </table> | |
28 | <p> | |
29 | Whenever we see a constant in a curryable-function such as the plus above, an actor<value<T> > (where T is the type of the constant) is, by default, automatically created for us. For instance, the example plus above is actually equivalent to:</p> | |
30 | <code><pre> | |
31 | <span class=identifier>plus</span><span class=special>(</span><span class=identifier>arg1</span><span class=special>, </span><span class=identifier>actor</span><span class=special><</span><span class=identifier>value</span><span class=special><</span><span class=keyword>int</span><span class=special>> >(</span><span class=identifier>value</span><span class=special><</span><span class=keyword>int</span><span class=special>>(</span><span class=number>6</span><span class=special>))) | |
32 | </span></pre></code> | |
33 | <p> | |
34 | A nifty shortcut is the val(v) utility function. The expression above is also equivalent to:</p> | |
35 | <code><pre> | |
36 | <span class=identifier>plus</span><span class=special>(</span><span class=identifier>arg1</span><span class=special>, </span><span class=identifier>val</span><span class=special>(</span><span class=number>6</span><span class=special>)) | |
37 | </span></pre></code> | |
38 | <p> | |
39 | actor<value<int> >(value<int>(6)) is implicitly created behind the scenes, so there's really no need to explicitly type everything but:</p> | |
40 | <code><pre> | |
41 | <span class=identifier>plus</span><span class=special>(</span><span class=identifier>arg1</span><span class=special>, </span><span class=number>6</span><span class=special>) | |
42 | </span></pre></code> | |
43 | <p> | |
44 | There are situations though, as we'll see later on, where we might want to explicily write val(x).</p> | |
45 | <p> | |
46 | Like arguments, values are also actors. As such, values can be evaluated through the actor's operator(). Such invocation gives the value's identity. Example:</p> | |
47 | <code><pre> | |
48 | <span class=identifier>cout </span><span class=special><< </span><span class=identifier>val</span><span class=special>(</span><span class=number>3</span><span class=special>)() << </span><span class=identifier>val</span><span class=special>(</span><span class=string>"Hello World"</span><span class=special>)(); | |
49 | ||
50 | </span><span class=identifier>prints </span><span class=identifier>out </span><span class=string>"3 Hello World"</span><span class=special>. | |
51 | </span></pre></code> | |
52 | <table border="0"> | |
53 | <tr> | |
54 | <td width="30"><a href="../index.html"><img src="theme/u_arr.gif" border="0"></a></td> | |
55 | <td width="30"><a href="arguments.html"><img src="theme/l_arr.gif" border="0"></a></td> | |
56 | <td width="20"><a href="variables.html"><img src="theme/r_arr.gif" border="0"></a></td> | |
57 | </tr> | |
58 | </table> | |
59 | <br> | |
60 | <hr size="1"> | |
61 | <p class="copyright">Copyright © 2001-2002 Joel de Guzman<br> | |
62 | <br> | |
63 | <font size="2">Use, modification and distribution is subject to the Boost Software | |
64 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
65 | http://www.boost.org/LICENSE_1_0.txt) </font> </p> | |
66 | </body> | |
67 | </html> |