Skip to content

Commit e3db74b

Browse files
committed
Describe recursive search on README
1 parent 69fd65e commit e3db74b

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

README.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ extracts the base numeric type from a numeric type `T`:
1313
For example,
1414

1515
| Input Type | Output Type |
16-
|---|---|
16+
|:-:|---|
1717
| `Float32` | `Float32` |
1818
| `ComplexF32` | `Float32` |
1919
| `Measurement{Float32}` | `Float32` |
2020
| `Dual{BigFloat}` | `BigFloat` |
2121
| `Rational{Int8}` | `Int8` |
22-
| `Quantity{Float32,Dimensions}` | `Float32` |
22+
| `Quantity{Float32, ...}` | `Float32` |
23+
| `Quantity{Measurement{Float32}, ...}` | `Float32` |
24+
| `Dual{Complex{Float32}}` | `Float32` |
2325

24-
Packages should write a method to `base_numeric_type`
25-
when the base type of a numeric type
26-
is not the first parametric type.
27-
For example, if you were to create a quantity-like type
28-
`Quantity{Dimensions,NumericType}`, you would need
29-
to write a custom interface.
26+
The standard behavior is to return the *first* type parameter,
27+
or, if that type has parameters of its own, to recursively
28+
take the first type parameter until a non-parameterized type is found.
3029

31-
But if the base type comes first,
32-
the default method will work.
30+
Packages should write a custom method for `base_numeric_type`
31+
if this behavior is incompatible with their type.
32+
For example, if you were to create a quantity-like type
33+
`Quantity{Dimensions,T}`, for a numeric type `T`,
34+
you would need to write a custom interface to return `T`.

0 commit comments

Comments
 (0)