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

`set(arr, reverse, arr2)` can change size

Open jariji opened this issue 3 months ago • 2 comments

Allow reversed objects to change size. E.g.

julia> @modify([10,20,30]) do xs
           xs[2:3]
       end
2-element Vector{Int64}:
 20
 30

Resolves #212.

jariji avatar Sep 13 '25 02:09 jariji

Thanks for trying it out @jariji!

It's not just KeyedArrays that need special handling after this PR. For example, StaticArrays now lose their "staticness" completely: set(SVector(1,2,3), reverse, 10:12) now returns a plain Vector without a static length. Maybe there are even more cases like that... But even with 2 major "special cases", I'm personally not fully convinced this is the way to go.

aplavin avatar Sep 13 '25 11:09 aplavin

But the extension issue itself is simple: you define a new set function that doesn't overload Accessors.set.

aplavin avatar Sep 13 '25 11:09 aplavin