-
Notifications
You must be signed in to change notification settings - Fork 17
statements
A statement is a language construct that is used to declare various language structures, make assignments, or provide flow of control; unlike an expression, a statement does not have a type and does not yield a value. Statements include a broad set of capabilities, such as: module and class declarations, method declarations, property and variable declarations, property and variable assignments, for
loops, if
statements, and the return
from a method or function.
Each statement that is defined by the language corresponds to a well-defined set of execution rules, which are detailed in the sections below. Each statement must be reachable, which means that in the course of execution, it must be possible for the execution to proceed to the statement, whether or not in reality that particular statement is ever actually executed; unless otherwise noted, it is an error for a statement to be unreachable.
Certain statements, by their nature, interrupt the normal sequential flow of statement execution, and are said to not complete. A statement that can complete is thus any statement that can be reasoned to allow execution to continue on to the next statement, which in turn makes the next statement reachable. The rules for statement completion are defined for each statement, but it is self-evident that a statement that cannot be reached does not complete.
Statements may also introduce scope. Scope represents a balanced (i.e. it both opens and closes) domain for declaration.
- Structural scope – Any statement or expression (such as a DeclarationStatement or a LambdaExpression) that results in an XVM structure (for example, a class, property, or method) represents a structural scope; each structure provides a scope within which further nested structures may exist. A nested structure is identified using the identity of its structural scope plus its own local identity, (for example, its name).
- Local variable scope – A nested scope within a block of execution that allows variables to be declared, whose names are visible only with that scope, and whose lifetimes are limited by the extent of that scope.
- A statement (or expression) can provide neither, either, or both of the above two forms of scope. A structural scope can additionally act as a capturing scope, which allows it to capture local variables (including
this
) from the containing scope.
Generally, when the term scope is used without specifying one of the explicit terms above, then “local variable scope” is implied.
The following sections will detail each of these statement forms:
Statement: DeclarationStatement AssertStatement AssignmentStatement BreakStatement ContinueStatement DoStatement ExpressionStatement ForStatement IfStatement ImportStatement LabeledStatement ReturnStatement StatementBlock SwitchStatement TryStatement UsingStatement VariableStatement WhileStatement