-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Constructing leaftypes by filling in dependent type parameters #22056
Comments
Alternatively one might want to declare the type immutable SArray{S <: Tuple, T} where {N = length(S), L = prod(S)} <: StaticArray{S, T, N}
data::NTuple{L,T}
end That might be cleaner. Would be good, though, for a method to be able to extract zerotuple(x::SArray{S, T} where {L = prod(S)}) = ntuple(d->zero(T), Val{L}) |
xref: this appears to be a potential solution for #5560 |
This also targets a different open issue (I'll try find it later) relating to allowing field types which are (more arbitrary) functions of the type parameters, which would be awesome to solve. |
xref: it is #18466 |
already implemented: #18466 (comment) |
We have some types that have "dependent" type parameters. For instance, in StaticArrays the
SArray
type is definedand an example for a 3x2x5 array might be
SArray{Tuple{3,2,5},Float32,3,30}
. In all "valid" (aka, useful) instances,N = length(S)
andL = prod(S)
. Consequently it might make sense for the package developer to be able to specify thatSArray{S, T}
constructs a leaftype, filling in the dependent parameters, rather than aUnionAll
type.Ref JuliaArrays/StaticArrays.jl#181.
The text was updated successfully, but these errors were encountered: