StaticArraysCore.jl icon indicating copy to clipboard operation
StaticArraysCore.jl copied to clipboard

Declare StaticArrays functions in StaticArraysCore

Open cscherrer opened this issue 1 year ago • 3 comments

Avoiding a dependency on all of StaticArrays requires being able to define all needed methods using only StaticArraysCore. For example, in this Accessors PR we need to be able to this code to work:

@inline delete(obj::StaticArraysCore.SVector, l::IndexLens) = deleteat(obj, only(l.indices))
@inline insert(obj::StaticArraysCore.SVector, l::IndexLens, val) = insert(obj, only(l.indices), val)

But deleteat and insert are declared (and defined) in StaticArrays itself, so these two lines of code currently require all of StaticArrays before the compiler will even accept them.

This seems to defeat the purpose of having a separation like this in the first place. This makes me wonder, could there be a minimal set of functions in StaticArrays that you'd consider useful for interfacing from "StaticArrays-optional" libraries like Accessors?

Could deleteat and insert, and whatever other functions you think might play a similar role, be declared in StaticArraysCore, and then implemented in StaticArray?

cscherrer avatar Sep 12 '22 20:09 cscherrer