Array slices as views - what's the state of affairs?


#1

I remember a long, long discussion about making array slices (i.e. A[:, :] syntax) to produce a view instead of a copy, but it turns out to be terribly hard to find a related thread. Can somebody point to it or describe a final status? In particular:

  1. Is this idea finally rejected or things may still change?
  2. What about special syntax? IIRC, A@[:, :] was mentioned in some announce, but I don’t see it working on a nightly build of 0.6.
  3. Any optimizations on compiler level? E.g. when a slice is proved to be read-only and underlying array to be unmodified during slice lifetime?

#2

Most of the discussion occurred on the umbrella Arraypocalypse issue. Most saliently, see this comment: https://github.com/JuliaLang/julia/issues/13157#issuecomment-221294186


#3

I have a PR so that you can just put @views in front of a whole block of code, even a whole function, to opt-in to slices=views: https://github.com/JuliaLang/julia/pull/20164