-
Notifications
You must be signed in to change notification settings - Fork 152
Open
Labels
designspeculative design related issuespeculative design related issue
Description
StaticArray
uses Tuple{1,2,3}
to encode the size:
StaticArrays.jl/src/StaticArrays.jl
Lines 73 to 76 in cee335d
abstract type StaticArray{S <: Tuple, T, N} <: AbstractArray{T, N} end | |
const StaticScalar{T} = StaticArray{Tuple{}, T, 0} | |
const StaticVector{N, T} = StaticArray{Tuple{N}, T, 1} | |
const StaticMatrix{N, M, T} = StaticArray{Tuple{N, M}, T, 2} |
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 #806 (comment))
mateuszbaran, c42f, hyrodium and mbaumanc42fc42f, mateuszbaran and hyrodium
Metadata
Metadata
Assignees
Labels
designspeculative design related issuespeculative design related issue