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.

13.27.2 Static Expressions and Values<br />

Static parameters are static expressions. A nat parameter denotes a value that has type NaturalStatic (which extends<br />

IntegerStatic). An int parameter denotes a value that has type IntegerStatic. A bool parameter denotes a value<br />

that has type BooleanStatic.<br />

Boolean static expressions may be combined using the operators ∧ , ∨ , ⊕ , ≡ , ↔ , NAND , NOR , = , ≠ , and →<br />

(See Appendix F for a discussion of <strong>Fortress</strong> operators.) to produce other static expressions denoting boolean static<br />

expressions. If both operands are boolean constant expressions, then the result is also a boolean constant expression.<br />

Character static expressions may be compared using the operators < , ≤ , ≥ , > , = , and ≠ to produce boolean static<br />

expressions. If both operands are character constant expressions, then the result is a boolean constant expression.<br />

Numeric static expressions may be compared using the operators < , ≤ , ≥ , > , = , and ≠ to produce boolean static<br />

expressions. If both operands are numeric constant expressions, then the result is a boolean constant expression.<br />

Numeric static expressions may be combined using the operators and functions + , − , × , · , / , ! , MIN , MAX ,<br />

√ , floor , ceiling , hyperfloor , hyperceiling , gcd , lcm, sin , cos , tan , arcsin , arccos , and arctan to produce<br />

new numeric static expressions. If the result is indeed a numeric static expression, and both operands are numeric<br />

constant expressions, then the result is also a numeric constant expression (except under certain circumstances—for<br />

example, sqrt 5 denotes a numeric constant expression, and so does (1 + sqrt 5)/2 , but sqrt((1 + sqrt 5)/2) does<br />

not, because it is too complicated).<br />

Where things get too complicated, a static expression evaluation backs off, widest-need processing steps in at a later<br />

stage and chooses an appropriate precision of floating-point arithmetic.<br />

13.28 Aggregate Expressions<br />

Syntax:<br />

Value ::= Aggregate<br />

Aggregate expressions evaluate to values that are themselves homogeneous collections of values. Evaluation of the<br />

subexpressions of an aggregate expression is performed in parallel. Evaluation steps of the subexpressions can be<br />

interleaved and even reordered to form an evaluation of the aggregates expression. See Section 4.4 for a discussion of<br />

parallel evaluation.<br />

Syntax for aggregate expressions are provided in the <strong>Fortress</strong> standard libraries for sets, maps, lists, tuples, matrices,<br />

vectors, and arrays.<br />

Set Expressions:<br />

Syntax:<br />

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

ExprList ::= Expr ( , Expr) ∗<br />

Set element expressions are enclosed in braces and separated by commas. <strong>The</strong> type of a set expression is SetT ,<br />

where T is the union type of the types of all element expressions of the set expression.<br />

Set containment is checked with the operator ∈ and the subset relationship is checked with the operator ⊆ . For<br />

example:<br />

evaluates to true and<br />

3 ∈ {0, 1, 2, 3, 4, 5}<br />

111

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

Saved successfully!

Ooh no, something went wrong!