Expressions



next up previous contents index
Next: Literals Up: No Title Previous: Termination

Expressions

An expression evaluates to an object in the Theta universe. This object is said to be the result or value of the expression. The simplest expressions are literals and identifiers that name their result object directly. More complex expressions are generally built up out of nested invocations of procedures. The result of such an expression is the value returned by the outermost invocation. A primary (7.16) is a limited kind of expression used in left hand sides of assignments (5.2), and also in invocation statements (8.1) and store statements (8.2).

An expression has a apparent type known at compile time. This type is derived from the types of the entities of which it is composed, e.g., the types of the variables used in it, and the types of the procedures it invokes. Compile-time type checking guarantees that the apparent type of an expression is a supertype of the object obtained by evaluating the expression.

Theta has prefix and infix operators for the common arithmetic and comparison operations, and uses the familiar syntax for array indexing (for example, "a[i]"). However, in Theta these notations are abbreviations for method invocations (7.11). This allows familiar notation to be used for user-defined types when appropriate.





theta-questions@lcs.mit.edu