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

What to do with `Array` now that it has fields ?

Open longemen3000 opened this issue 1 year ago • 6 comments

while testing #86 , some downstream packages (Flatten.jl) fail because now Array{N,T} has fields (size::NTuple{Int,N} and ref::MemoryRef{T}). is this something that needs to be fixed on Flatten or ConstructionBase?

longemen3000 avatar Jul 16 '24 05:07 longemen3000

We have getproperties([]) == () so getproperties and setproperties should be consistent with that, e.g. not see the fields. About constructorof and getfields should be aware of them OTOH. See also

  • https://juliaobjects.github.io/ConstructionBase.jl/dev/#the-raw-level
  • https://juliaobjects.github.io/ConstructionBase.jl/dev/#the-semantic-level

jw3126 avatar Jul 16 '24 05:07 jw3126

Does the constrictor Array(size, ref) work?

And do you have a link to the break in Flatten.jl?

(We may need a costom constructorof here)

rafaqz avatar Jul 16 '24 07:07 rafaqz

Does the constrictor Array(size, ref) work?

No, Array(ref, size) does not work. Still, I think we should provide it. To me, one aspect of this package is to provide a constructor from fields no matter what. We do this in many other cases even lambda functions.

jw3126 avatar Jul 16 '24 08:07 jw3126

Yeah, absolutely. We can define a custom constructorof for Array.

rafaqz avatar Jul 16 '24 09:07 rafaqz

provide a constructor from fields no matter what

Yes, nice to have it whenever possible. Ie, constructorof(array)(getfields(A)) won't work on 1.10- because it doesn't have any fields, but will on 1.11.

aplavin avatar Jul 16 '24 09:07 aplavin

Yeah, it will need to be in a @static check on Julia version

rafaqz avatar Jul 16 '24 10:07 rafaqz