-
Notifications
You must be signed in to change notification settings - Fork 41
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
replace_storage
but no eltype
restriction
#180
Comments
Sorry I did not reply to your comment on #175, I'll write my thoughts here. The problem with Alternatively, one would need to figure out a way to "adjust" the outer type |
Yes, I guess that's true; I don't know how to automatically merge the replaced types into the struct type parameters. Would you be interested in a PR that adds an interface to specify this? Something like eltype_from_fields(::Type{<:Foo}, T) = Foo{T} |
Yes, a PR is definitely welcome. As long as we mark this new interface as experimental (IMO the design is not completely clear) I think there's no harm in adding this. In particular, it may require a little bit of tinkering to figure out whether it can also be useful for the collection mechanism in |
After working a bit on #175, I feel that
replace_storage
works well for arrays of primitive types, but it doesn't work well for wrapper array types.Consider the following two array types:
For array types like
ArrayOfMyVectors
, it is reasonable to want to return view intobuffer
wrapped as aMyVector
. In other words,Now, suppose you have the following:
This won't work, because the
eltype(x.bar)
is originallyMyVector{Int, Vector{Int}}
and theeltype
of the replaced storage isMyVector{Int, SubArray{...}}
. Note that unlike JuliaArrays/ArraysOfArrays.jl#2 theeltype
/getindex
are internally consistent forArrayOfMyVectors
.So, would it make sense to have a variant (different function or keyword arg) that behaved like
replace_storage
but returned aStructArray
with a totally neweltype
? Am I just missing something completely here?The text was updated successfully, but these errors were encountered: