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.

for tokens.<br />

For readability, plural forms of the unit names are defined as equivalent to the corresponding singular forms; thus one<br />

can write meters per second , for example. Standard SI prefixes may be used on both the name and the symbol, so<br />

that nanometer and nm are also units of the dimension named Length, related to meter and m by a conversion<br />

factor of 10 −9 .<br />

Every dimension may have a default unit that is used for representing values of quantities of that dimension if no unit<br />

is specified explicitly. <strong>The</strong> <strong>Fortress</strong> standard libraries define these default dimensions and units:<br />

Length meter MagneticFlux weber<br />

Mass kilogram MagneticFluxDensity tesla<br />

Time second Inductance henry<br />

Frequency hertz Velocity meters per second<br />

Force newton Acceleration meters per second squared<br />

Pressure pascal Angle radian<br />

Energy joule SolidAngle steradian<br />

Power watt LuminousIntensity candela<br />

Temperature kelvin LuminousFlux lumen<br />

Area square meter Illuminance lux<br />

Volume cubic meter RadionuclideActivity becquerel<br />

ElectricCurrent ampere AbsorbedDose gray<br />

ElectricCharge coulomb DoseEquivalent sievert<br />

ElectricPotential volt AmountOfSubstance mole<br />

Capacitance farad CatalyticActivity katal<br />

Resistance ohm MassDensity kilograms per cubic meter<br />

Conductance siemens<br />

In addition, the <strong>Fortress</strong> standard libraries define the dimension Information with units bit and byte (and the plurals<br />

bits and bytes), a byte being equal to 8 bits. To avoid confusion, SI prefixes are not provided for these units; instead,<br />

programmers must use appropriate powers of 2 or 10, for example 10 6 bits or 2 20 bits .<br />

Here are some examples of the use of dimensions and units:<br />

x: R64 Length = 1.3 m<br />

t: R64 Time = 5 s<br />

v: R64 Velocity = x/t<br />

w: R64 Velocity in nm/s = 17 nm/s<br />

x: R64 Velocity in furlongs per fortnight = v in furlongs per fortnight<br />

Dimensions and units can be multiplied, divided, and raised to rational powers to produce new dimensions and units.<br />

Both the numerator and the denominator of a rational power of a dimension or a unit must be a valid nat parameter<br />

instantiation (as described in Section 11.2). Multiplication can be expressed using juxtaposition or · ; division can be<br />

expressed using / or per. <strong>The</strong> syntactic operators square and cubic may be applied to a dimension or unit in order<br />

to raise it to the second power, third power, respectively; the special postfix syntactic operators squared and cubed<br />

may be used for the same purpose. <strong>The</strong> syntactic operator inverse may be applied to a dimension or unit to divide it<br />

into 1. All of these syntactic operators are merely syntactic sugar, expanded before type checking.<br />

grams per cubic centimeter<br />

meter per second squared<br />

inverse ohms<br />

One can also write 1/X as a synonym for X −1 if X is either a dimension or a unit.<br />

Most numerical values in <strong>Fortress</strong> are dimensionless quantity values. Multiplying or dividing a dimensionless value<br />

by a unit produces a dimensioned value; thus 5 s is the dimensioned value equal to five seconds, which has numerical<br />

147

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

Saved successfully!

Ooh no, something went wrong!