New Issue: Should we have factory functions to create arrays?

18163, "ronawho", "Should we have factory functions to create arrays?", "2021-08-05T00:09:51Z"

We have factory functions that can create bytes from a pointer:

  • createBytesWithBorrowedBuffer
  • createBytesWithOwnedBuffer
  • createBytesWithNewBuffer

We also have similar ones for strings. I think we should add something like this for arrays. We have makeArrayFromPtr from the 'external' array support, which can be used but that's not user-facing or stable. Here I'm thinking of something user-facing and more consistent with the bytes/string versions where we create an array from either a pointer or bytes. Note that for arrays we'll also want to provide a way to specify the domain, so the interface won't be exactly the same. Maybe something like:

proc createArrayWith*Buffer(buffer: bytes, dom:domain={0..<buffer.size}) {}
proc createArrayWith*Buffer(buffer: c_ptr(?t), dom: domain) {}

For some context/motivation, we started using makeArrayFromPtr in Arkouda Optimize server conversions for client-server array transfers by ronawho · Pull Request #880 · Bears-R-Us/arkouda · GitHub and that made me want a stable version of it. Another user was also trying to create an array from an existing pointer in Building a distributed chapel array with multiple pointers.