docs: "Interface Introduction" chapter updated

This commit is contained in:
Mateusz Pusz
2024-06-22 10:57:06 +02:00
parent e8c1a4ac1d
commit 9d57cf2758

View File

@ -22,6 +22,9 @@ behind this is that:
a user's written code, a new idiom in the library is to use the same identifier for
a type and its instance.
Also, to prevent possible issues in compile-time logic, all of the library's entities must be
marked `final`. This prevents the users to derive own strong types from them, which would
prevent expression template simplification of equivalent entities.
## Strong types instead of aliases
@ -234,6 +237,17 @@ the resulting expression template.
| `power<A, 3>, per<A>` | `power<A, 2>` |
| `A, per<power<A, 2>>` | `{identity}, per<A>` |
It is important to notice here that only the elements with exactly the same type are being
simplified. This means that, for example, `m/m` results in `one`, but `km/m` will not be
simplified. The resulting derived unit will preserve both symbols and their relative
magnitude. This allows us to properly print symbols of some units or constants that require
such behavior. For example, the Hubble constant is expressed in `km⋅s⁻¹⋅Mpc⁻¹`, where both
`km` and `Mpc` are units of _length_.
Also, to prevent possible issues in compile-time logic, all of the library's entities must be
marked `final`. This prevents the users to derive own strong types from them, which would
prevent expression template simplification of equivalent entities.
4. **Repacking**
In case an expression uses two results of other operations, the components of its arguments are repacked