julia icon indicating copy to clipboard operation
julia copied to clipboard

Add `Base.wrap` to docs

Open fatteneder opened this issue 1 year ago • 5 comments

I thought that's reasonable in the light that view was not implemented: https://github.com/JuliaLang/julia/pull/52049#issuecomment-1848711619

fatteneder avatar Feb 15 '24 09:02 fatteneder

Is wrap supposed to be a generic function for wrapping data in other structs?

Tokazama avatar Feb 15 '24 16:02 Tokazama

Its meant to wrap an Array around a Memory: https://github.com/JuliaLang/julia/blob/e460d357d48d121f55e8007d35f6848e9983cfac/base/array.jl#L3066-L3072

fatteneder avatar Feb 15 '24 16:02 fatteneder

Its meant to wrap an Array around a Memory:

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?

Tokazama avatar Feb 15 '24 17:02 Tokazama

I think not, because

  • it was added as a safe counterpart to unsafe_wrap, which itself is only meant to wrap an Array around a Ptr,
  • the arguments are specific to Array (what would the dims 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.

fatteneder avatar Feb 16 '24 08:02 fatteneder

Oops, I forgot to add this to the docs when I wrote it. Thanks for putting it in!

MasonProtter avatar Feb 16 '24 15:02 MasonProtter

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

vtjnash avatar Feb 17 '24 18:02 vtjnash