@@ -3,9 +3,38 @@ import Tricks: static_fieldnames, static_fieldtypes
3
3
const DEFAULT_DIM_BASE_TYPE = FixedRational{Int32,2 ^ 4 * 3 ^ 2 * 5 ^ 2 * 7 }
4
4
const DEFAULT_VALUE_TYPE = Float64
5
5
6
- abstract type AbstractQuantity{T,D} end
6
+ """
7
+ AbstractDimensions{R}
8
+
9
+ An abstract type for dimension types. `R` is the type of the exponents of the dimensions,
10
+ and by default is set to `DynamicQuantities.DEFAULT_DIM_BASE_TYPE`.
11
+ AbstractDimensions are used to store the dimensions of `AbstractQuantity` objects.
12
+ Together these enable many operators in Base to manipulate dimensions.
13
+ This type has generic constructors for creating dimension objects, so user-defined
14
+ dimension types can be created by simply subtyping `AbstractDimensions`, without
15
+ the need to define many other functions.
16
+
17
+ The key function that one could wish to overload is
18
+ `DynamicQuantities.dimension_name(::AbstractDimensions, k::Symbol)` for mapping from a field name
19
+ to a base unit (e.g., `length` by default maps to `m`). You may also need to overload
20
+ `DynamicQuantities.constructor_of(::Type{T})` in case of non-standard construction.
21
+ """
7
22
abstract type AbstractDimensions{R} end
8
23
24
+ """
25
+ AbstractQuantity{T,D}
26
+
27
+ An abstract type for quantities. `T` is the type of the value of the quantity,
28
+ and `D` is the type of the dimensions of the quantity. By default, `D` is set to
29
+ `DynamicQuantities.DEFAULT_DIM_TYPE`. `T` is inferred from the value in a calculation,
30
+ but in other cases is defaulted to `DynamicQuantities.DEFAULT_VALUE_TYPE`.
31
+ It is assumed that the value is stored in the `:value` field, and the dimensions
32
+ object is stored in the `:dimensions` field. These fields can be accessed with
33
+ `ustrip` and `dimension`, respectively. Many operators in `Base` are defined on
34
+ `AbstractQuantity` objects, including `+, -, *, /, ^, sqrt, cbrt, abs`.
35
+ """
36
+ abstract type AbstractQuantity{T,D} end
37
+
9
38
"""
10
39
Dimensions{R} <: AbstractDimensions{R}
11
40
0 commit comments