JuliaPhysics / JuliaPhysics/DynamicQuantities.jl

Compatibility with `zero(::Type{T})`

Open
#76 10 comments 0 reactions 0 assignees View on GitHub
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.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.