-
Notifications
You must be signed in to change notification settings - Fork 151
Open
Labels
designspeculative design related issuespeculative design related issuefeaturefeatures and feature requestsfeatures and feature requestsup for grabsImplement me, I'm yours!Implement me, I'm yours!
Description
One thing that was realized in the AbstractArray
interface is that traits are a convenient and powerful way of expressing ways of interacting with different types of arrays, the prototypical exampling being LinearFast
vs LinearSlow
. I wanted to discuss some possible traits that would be useful for StaticArrays.jl while keeping in mind that with future language enhancements (e.g. the trait system experiments of Traitor.jl) might make them easier to use and interface into Base
in the future.
- Dispatch on size. We could have some kind of
Dimensions
trait (@timholy suggestedSDims
to complementBase.Dims
). Unlike FixedSizeArrays, the size isn't specified in the abstractStaticVector{T}
, while the package is meant to use thesize()
on types interface, it doesn't make it easy to allow, e.g., any 3-vector. Introducing a trait would at least allow an "official" way of doing that. Speculatively, this could be extended so thatSDims <: AbstractDimensions
andBase.Array
etc have a dimensions trait with run-time size information (but compile-time rank). The dimensions trait could be combined with the "indices" trait being proposed/used in Base for non-1-based indexing. - Mutable vs. immutable. Or, more specifically, does
setindex!
work? Most algorithms in Base are defined usingsimilar
but that doesn't work for immutables, and it is a pain to define alternatives here that things other thanStaticArray
can't use at all. - Perhaps stack-allocated vs heap-allocated? We would put extra effort in for stack-allocated things so that we never make new heap allocations. This is obviously related to Mutable vs Immutable and
similar
vssimilar_type
.
Any thoughts appreciated. Is it a good idea to be defining types here, in this package?
Metadata
Metadata
Assignees
Labels
designspeculative design related issuespeculative design related issuefeaturefeatures and feature requestsfeatures and feature requestsup for grabsImplement me, I'm yours!Implement me, I'm yours!