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.

{0, 1, 2} ⊆ {0, 3, 2}<br />

evaluates to false .<br />

Map Expressions:<br />

Syntax:<br />

Aggregate ::= { [EntryList] }<br />

EntryList ::= Entry ( , Entry) ∗<br />

Entry ::= Expr ↦→ Expr<br />

Map entries are enclosed in curly braces, separated by commas, and matching pairs are separated by ↦→. <strong>The</strong> type of<br />

a map expression is MapS, T where S is the union type of the types of all left-hand-side expressions of the map<br />

entries, and T is the union type of the types of all right-hand-side expressions of the map entries. This type can be<br />

abbreviated as {S ↦→ T } .<br />

A map m is indexed by placing an element in the domain of m enclosed in brackets immediately after an expression<br />

evaluating to m . Thus, the index is rendered as a subscript. For example, if:<br />

m = {’a’ ↦→ 0, ’b’ ↦→ 1, ’c’ ↦→ 2}<br />

then m ’b’ evaluates to 1 . In contrast, m’x’ throws a NotFound exception, as ’x’ is not an index of m .<br />

List Expressions:<br />

Syntax:<br />

Aggregate ::= 〈 [ExprList] 〉<br />

List element expressions are enclosed in angle brackets 〈 and 〉 and are separated by commas. <strong>The</strong> type of a list<br />

expression is ListT where T is the union type of the types of all element expressions. This type can be abbreviated<br />

as 〈T 〉 .<br />

A list l is indexed by placing an index enclosed in square brackets immediately after an expression evaluating to l .<br />

Thus, the index is rendered as a subscript. Lists are always indexed from 0 . For example:<br />

evaluates to 1 .<br />

〈3, 2, 1, 0〉 2<br />

Array Expressions<br />

Syntax:<br />

Aggregate ::= [ (Expr | ; ) ∗ ]<br />

Array element expressions are enclosed in brackets. Element expressions along a row are separated only by whitespace.<br />

Two dimensional array expressions are written by separating rows with newlines or semicolons. If a semicolon<br />

appears, whitespace before and after the semicolon is ignored. <strong>The</strong> parts of higher-dimensional array expressions are<br />

separated by repeated-semicolons, where the dimensionality of the result is equal to one plus the number of repeated<br />

semicolons. <strong>The</strong> type of a k-dimensional array expression is ArrayT[n 0 , · · · , n k−1 ] , where T is the union type of<br />

the types of the element expressions and n 0 , ..., n k−1 are the sizes of the array in each dimension. This type can be<br />

abbreviated as T[n 0 , · · · , n k−1 ] .<br />

A k-dimensional array A is indexed by placing a sequence of k indices enclosed in brackets, and separated by commas,<br />

after an expression evaluating to A. Thus, the index is rendered as a subscript. By default arrays are indexed from 0.<br />

<strong>The</strong> horizontal dimension of an array is the last dimension mentioned in the array index. For example:<br />

112

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

Saved successfully!

Ooh no, something went wrong!