11# Units and tags
22
3- ## Realms
3+ ## Usage
4+
5+ ### Literals
6+
7+ Units can be used with literals. You may directly add the name of a unit
8+ or if it is unit-expression you may add those between parentheses.
9+
10+ ```
11+ let foo = 1.0 m
12+ let bar = 100.0 cm
13+ let baz = 120.0 (km/h)
14+ ```
15+
16+ The type of these literals is:
17+ - The base type, in the above case ` real ` , or a floating point number.
18+ - A unit tag, which consists of:
19+ * The realm, like: si
20+ * A quantity expression condenced to a vector of exponentions.
21+
22+ ## Declarations
23+
24+ ### Realms
425A realm contains a set of units and constants. The most well know realm is
526the "SI International System of Units". But you can imagine units like pixels
627that do not fall within this realm.
@@ -16,7 +37,7 @@ declare realm font
1637declare realm screen
1738```
1839
19- ## Base Quantities
40+ ### Base Quantities
2041
2142Here we declare the base quantities, each quantity may exist in different realms.
2243You can specify the default realm so that there is a short-cut when adding a
@@ -32,7 +53,7 @@ declare quantity amount_of_substance default si
3253declare quantity luminous_intensity default si
3354```
3455
35- ## Derived Quantities
56+ ### Derived Quantities
3657
3758```
3859declare quantity frequency = time^-1
@@ -48,7 +69,7 @@ declare quantity electrical_resistance = length^2 * mass * time^-3 * electric_cu
4869```
4970
5071
51- ## Base unit
72+ ### Base unit
5273A base unit is a standard quantity in a realm. For example ` m ` (meter) is the
5374base unit ` 1.0 ` of the ` length ` quantity in the ` si ` realm.
5475
@@ -64,7 +85,7 @@ declare unit Hz = 1.0 si frequency
6485declare unit ohm "Ω" = 1.0 si electrical_resistance
6586```
6687
67- ## Scale unit
88+ ### Scale unit
6889There are also scaled units.
6990
7091```
0 commit comments