-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
RFC: WIP: start to remove pointer(::Array) & friends #6618
Conversation
avoiding the silent automatic conversion that now is the default, as shown in my example code, and generally discouraging passing around arrays as pointer in julia code |
Aside from it being a hugely breaking change, I can see an argument for removing |
Is there stronger motivation for this change than I'm aware of? While I know it's dangerous, I would shed a tear if this went away, at least if it happens before we have fast array views. One way I'm using pointer is to provide views of tiled arrays, all allocated with contiguous memory. Once we get fast views (that also support bounds-checking in a nice way), I won't need that, but currently
seems to be the best way to get the features I want. |
I think the pointer and convert(::Ptr,Array) functions make it altogether too easy to make unmanaged pointers. Leading to unsafe situations such as the following:
Furthermore, it encourages
ccall(:a, Ret, (Ptr{T},), pointer(T))
, which is identical to the call without thepointer
, but is potentially missing a GC root.However, attempting to remove the pointer function from base reveals a rather heavy dependence on this function. A few of the usages of the function in the blas libraries are there to compute an offset pointer. However, many or most of these usages seem largely unnecessary.