JuliaMath / JuliaMath/FixedPointNumbers.jl
idea for a breaking release: type safety, by relying on TypeDomainNaturalNumbers.jl
- Dominant language
- Julia
- Stars
- 95
- Forks
- 38
- Avg merge
- 13m
- Merged PRs (30d)
- 2
Description
I see you're planning several possible breaking changes here, so here's another breaking idea.
I've got a package, TypeDomainNaturalNumbers.jl, which makes it possible to describe number sets like "the nonnegative integers" using Julia's type system: https://juliahub.com/ui/Packages/General/TypeDomainNaturalNumbers/
This would be useful here for giving the "number of fraction bits" type parameter of `FixedPoint` a type constraint, for greater type safety:
https://github.com/JuliaMath/FixedPointNumbers.jl/blob/3242f10050e5e3c3b75d099a71b322631cc52b3a/src/FixedPointNumbers.jl#L27-L27
> ```julia
> abstract type FixedPoint{T <: Integer, f <: NonnegativeInteger} <: Real end
> ```
This would mean that things like `FixedPoint{T, 2//3}`, `FixedPoint{T, :sym}` or `FixedPoint{T, -1}` would throw.
PS: my package is large, but, TBH, only a small fraction of it is required for implementing `NonnegativeInteger`. I hate to say this, but it *might* make sense for `FixedPointNumbers` to depend on a new, minimal, package, extracted from the source of `TypeDomainNaturalNumbers`. Obviously I'd try to make the two packages as compatible as possible while keeping the small package as tiny as possible. Say if this sounds interesting.
PSPS: I think there may be low-hanging fruit for optimizing the compilation latency of my package. I'm looking for a representative workload which I could benchmark before plucking these. So, if you find the latency problematic, please open an issue.
FTR: upstream invalidations are currently also an issue regarding latency. I'll start making more PRs to JuliaLang/julia to try to address this.
Contributor guide
Assessment
This issue has not been assessed yet.