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.

Chapter 35<br />

Dimensions and Units Declarations<br />

Syntax:<br />

DimUnitDecl ::= dim Id [ = DimRef ] [default Unit]<br />

| (unit | SI unit ) Id + [ : DimRef ] [ = Expr]<br />

| dim Id [ = DimRef ] (unit | SI unit ) Id + [ = Expr]<br />

35.1 Dimensions Declarations<br />

Dimensions may be explicitly declared; every declared dimension must be declared at the top level of a program<br />

component, not within a block expression or trait. Other dimensions may be constructed by multiplying and dividing<br />

other dimensions, as described in Chapter 18. An explicitly declared dimension may be a base dimension (with no<br />

definition specified) or a derived dimension (with a definition specified in the form of an initialization expression).<br />

<strong>The</strong> set of all dimensions has the algebraic structure of a free abelian group. <strong>The</strong> identity element of this group is the<br />

dimension Unity, which represents dimensionlessness.<br />

For every two dimensions D and E , there is a dimension DE (which may also be written D · E ), corresponding to<br />

the product of the dimensions D and E and a dimension D/E , corresponding to the quotient of the dimensions D<br />

and E . <strong>The</strong> syntactic sugar 1/D is equivalent to Unity/D for all dimensions D . A dimension can be raised to a<br />

rational power where both the numerator and the denominator of the rational power must be a valid nat parameter<br />

instantiation (as described in Section 11.2); D 0 is the same as Unity, D 1 is the same as D , and D m+n is the same<br />

as D m D n . <strong>The</strong> syntactic sugar D −n is the same as Unity/D n .<br />

Here are some examples of base dimension declarations:<br />

dim Length<br />

dim Mass<br />

dim Time<br />

dim ElectricCurrent<br />

Here are some examples of computed dimensions:<br />

Length/Time<br />

Velocity/Time<br />

Length · Mass/Time 2<br />

Length Mass Time −2<br />

ElectricCurrent/Length 2 236

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

Saved successfully!

Ooh no, something went wrong!