19.11.2014 Views

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

The Fortress Language Specification - CiteSeerX

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

• element types of a tuple type can be separated by the token × instead of by commas, with enclosing parentheses<br />

elided and<br />

• element types of a tuple type that have the same type can be abbreviated using superscripts.<br />

Here are some examples:<br />

R64 × R64 → R64<br />

N → N × N throws IOException<br />

(N, N) → N × N<br />

Z 3 → Z<br />

Parameter types are contravariant but return types are covariant; arrow type “A → B throws C ” is a subtype of<br />

arrow type “D → E throws F ” if and only if:<br />

• D is a subtype of A and<br />

• B is a subtype of E and<br />

• for all X in C, there exists Y in F such that X is a subtype of Y .<br />

Coercion between arrow types are described in Section 17.7.<br />

An arrow type excludes any nonarrow type other than Object. However, arrow types do not exclude other arrow types<br />

because of overloading as described in Chapter 33.<br />

8.6 Bottom Type<br />

Syntax:<br />

TypeRef ::= BottomType<br />

<strong>Fortress</strong> provides a special bottom type, BottomType, which is an uninhabited type. No value in <strong>Fortress</strong> has the<br />

bottom type; throw and exit expressions have the bottom type. <strong>The</strong> bottom type is a subtype of every type.<br />

Intersection of any exclusive types is the bottom type.<br />

8.7 Types in the <strong>Fortress</strong> Standard Libraries<br />

<strong>The</strong> <strong>Fortress</strong> standard libraries define simple standard types for literals such as BooleanLiteralb , () (pronounced<br />

“void”), Character, String, and Numeraln, m, r, v for appropriate values of b , n , m , r , and v (See Section 13.1<br />

for a discussion of <strong>Fortress</strong> literals). Moreover, there are several simple standard numeric types. <strong>The</strong>se types are<br />

mutually exclusive; no value has more than one of them. Values of these types are immutable.<br />

<strong>The</strong> numeric types share the common supertype Number. <strong>Fortress</strong> includes types for arbitrary-precision integers (of<br />

type Z), their unsigned equivalents (of type N), rational numbers (of type Q), fixed-size representations for integers<br />

including the types Z8, Z16, Z32, Z64, Z128, their unsigned equivalents N8, N16, N32, N64, N128, floating-point<br />

numbers (described below), intervals (of type IntervalX , abbreviated as 〈|X|〉 , where X can be instantiated with<br />

any number type), and imaginary and complex numbers of fixed size (in rectangular form with types Cn for n =<br />

16, 32, 64, 128, 256 and polar form with type PolarX where X can be instantiated with any real number type).<br />

For floating-point numbers, <strong>Fortress</strong> supports types R32 and R64 to be 32 and 64-bit IEEE 754 floating-point numbers<br />

respectively, and defines two functions on types: DoubleF is a floating-point type twice the size of the floatingpoint<br />

type F , and ExtendedF is a floating-point type sufficiently larger than the floating-point type F to perform<br />

summations of “reasonable” size. 1<br />

1 This formulation of floating-point types follows a proposal under consideration by the IEEE 754 committee.<br />

67

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

Saved successfully!

Ooh no, something went wrong!