Statements
Syntax:
statement ;
General:
A statement is an expression. The term "expression" used here does
not mean the same thing as an expression in messiah's
Command mode. Since scripting has been added to
messiah the definition of what an expression is has changed
somewhat. There are various reasons for this change that we
won't get into but an expression in Command mode may now
contain multiple statements.
The term "expression" used here follows the mathematical definition of an expression: a statement that evaluates to some value. So for example the following are valid statements:
5;
a = 2 * (5 + 3);
foo.bar();
Each of these statements evaluates to some value. The simplest case is the first one that just evaluates to the number 5. The second one evaluates to 16 and the last one evaluates to the value returned by the function foo.bar(). The second one might look a little tricky because of that equals sign in there, you might be thinking back to you're algebra and saying "hey, there's an equality sign in there, that's an equation not an expression!" This is true, however the value of the left side of the equation (after the equation is solved) is used as the value of the expression. So in this case the expression on the right hand side of the equals sign is evaluated, then it is assigned to the variable a, finally the value of a is used as the value of the statement. Let's look at an example:
int tmp()
{
int a = 5;
int b = 0;
b = (a = a + 5 );
return ( b );
}
The line b = ( a = a + 5); demonstrates that the equation a = a + 5 simplifies to the value of a after the value a + 5 is assigned to it. The value assigned to b is 10.
Converted from CHM to HTML with chm2web Pro 2.82 (unicode) |