JuliaArrays / JuliaArrays/StaticArrays.jl
Use `StaticInteger`s instead of `Tuple{1,2,3}` in `StaticArray` type parameter?
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 844
- Forks
- 159
- Avg merge
- 3d 21h
- Merged PRs (30d)
- 3
Description
StaticArray uses Tuple{1,2,3} to encode the size:
Arguably, the type parameters of Tuple should be types. Otherwise, such Tuple does not have an instance. It also confuses some users (including me when I first saw this): What does Tuple{3} mean in StaticArrays? - Usage / First steps - JuliaLang.
A better solution may be to use Tuple{StaticInteger{1},StaticInteger{2},StaticInteger{3}} instead of Tuple{1,2,3}. For example, a possible implementation of SArray would be
struct SArray{N, S <: NTuple{N,StaticInteger}, T, L} <: StaticArray{S, T, N}
data::NTuple{L,T}
size::S
end
const SVector{S, T} = SArray{1, Tuple{StaticInteger{S}}, T, S}
const SMatrix{S1, S2, T, L} = SArray{2, Tuple{StaticInteger{S1}, StaticInteger{S2}}, T, L}
(Early discussion in https://github.com/JuliaArrays/StaticArrays.jl/issues/806#issuecomment-655279036)
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read src/StaticArrays.jl at lines 73-76, then review the early discussion in issue #806 and the linked Julia Discourse thread. Compare the current Tuple-based size parameters with the proposed StaticInteger representation and determine whether the design is acceptable. Done requires an agreed representation and consistent implementation of the affected StaticArray types.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100