julia
julia copied to clipboard
Add `Base.wrap` to docs
I thought that's reasonable in the light that view
was not implemented: https://github.com/JuliaLang/julia/pull/52049#issuecomment-1848711619
Is wrap
supposed to be a generic function for wrapping data in other structs?
Its meant to wrap an Array
around a Memory
:
https://github.com/JuliaLang/julia/blob/e460d357d48d121f55e8007d35f6848e9983cfac/base/array.jl#L3066-L3072
Its meant to wrap an
Array
around aMemory
:https://github.com/JuliaLang/julia/blob/e460d357d48d121f55e8007d35f6848e9983cfac/base/array.jl#L3066-L3072
But is it intended to be a method that is extended for similar use cases?
I think not, because
- it was added as a safe counterpart to
unsafe_wrap
, which itself is only meant to wrap anArray
around aPtr
, - the arguments are specific to
Array
(what would thedims
argument be use for with a generic struct?), - I think there is no functionality yet that builds upon
wrap
, so no need to extend it.
Oops, I forgot to add this to the docs when I wrote it. Thanks for putting it in!
The generic version is generally view
, though that usually returns an immutable-axes container, while this is fairly specific to making a mutable Array wrapper around Memory. So someone else might extend this, but there is not too many envisioned cases where there is a similar set of factors. It probably only would be extended for other near-equivalent cases, like converting some struct that wrapped a Memory into a type that wraps an Array, or doing something similar with AtomicMemory