19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

• top-level variable declarations (see Section 6.2)<br />

• dimension declarations (see Chapter 18)<br />

• unit declarations (see Chapter 18)<br />

• top-level type aliases (see Section 8.9)<br />

• test declarations (see Chapter 19)<br />

• top-level property declarations (see Chapter 19)<br />

Local declarations occur in another declaration or in some expression (or both). <strong>The</strong>se may be one of the following:<br />

• method declarations (see Section 9.2): these occur in trait and object declarations and object expressions<br />

• field declarations (see Section 10.2): these occur in object declarations and object expressions, and include field<br />

declarations in the parameter list of an object declaration<br />

• local function declarations (see Section 6.4): these occur in block expressions<br />

• local variable declarations (see Section 6.3): these occur in block expressions<br />

• local property declarations (see Chapter 19): these occur in trait and object declarations and object expressions<br />

• labeled blocks (see Section 13.13)<br />

• static-parameter declarations, which may declare type parameters, nat parameters, int parameters, bool<br />

parameters, dim parameters, unit parameters, opr parameters, or ident parameters (see Chapter 11): these<br />

occur in static-parameter lists of trait and parameterized object declarations, top-level type aliases, top-level<br />

function declarations, and method declarations<br />

• hidden-type-variable declarations: these occur in where clauses of trait and object declarations, top-level function<br />

declarations, and method declarations<br />

• type aliases in where clauses: these occur in where clauses of trait and object declarations, top-level function<br />

declarations, and method declarations<br />

• (value) parameter declarations, which may be keyword-parameter declarations: these occur in parameter lists of<br />

parameterized object declarations, top-level function declarations, method declarations, local function declarations,<br />

and function expressions (but do not include nontransient parameter declarations in the parameter list of<br />

an object declaration, which are field declarations)<br />

Some declarations are syntactic sugar for other declarations. Throughout this chapter, we consider declarations after<br />

they have been desugared. Thus, apparent field declarations in trait declarations are actually method declarations (as<br />

described in Section 9.2), and a dimension and unit declaration may desugar into several separate declarations (as<br />

described in Section 35.3). After desugaring, the kinds of declarations listed above are disjoint.<br />

In addition to these explicit declarations, there are two cases in which names are declared implicitly: <strong>The</strong> special name<br />

self is implicitly declared as a parameter by some method declarations. See Section 9.2 for details about when self<br />

is implicitly declared. <strong>The</strong> name result is implicitly declared by the ensures clause of a contract. See Section 12.4<br />

for a discussion of contracts.<br />

Trait declarations, object declarations, top-level type aliases, type-parameter declarations, and hidden-type-variable<br />

declarations are collectively called type declarations; they declare names that refer to types (see Chapter 8). Dimension<br />

declarations and dim -parameter declarations are dimension declarations, and unit declarations and unit -parameter<br />

declarations are unit declarations. Parameterized object declarations, top-level function declarations, method declarations,<br />

and local function declarations are collectively called functional declarations. Nonparameterized object declarations,<br />

top-level variable declarations, field declarations, local variable declarations, and (value) parameter declarations<br />

(including implicit declarations of self ) are collectively called variable declarations. Nonparameterized object<br />

55

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!