JuliaPhysics / JuliaPhysics/DynamicQuantities.jl
Compatibility with `zero(::Type{T})`
- Dominant language
- Julia
- Stars
- 155
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
It seems like a reason DynamicQuantities.jl is incompatible with many libraries right now is due to their usage of `zero(::Type{T})`, which works for Unitful but not for DynamicQuantities.jl.
Therefore I wonder if there is a way of defining something like:
```julia
zero(::Type{Q}) where {Q<:AbstractQuantity} = AutoQuantityZero{Q}()
```
which could avoid checking for any dimension errors in operations, and act as a _neutral zero_.
The problem with this is type instability, but perhaps that's better than simply throwing an error...? Then as packages adapt they would get type stability again. (And of course any package already using `zero(::T)` would maintain type stability).
Thoughts @gaurav-arya?
We could even think of adding a special boolean field to `Quantity` to indicate this... thus making everything type stable. But it's a bit worrisome...
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.