
Tim Hochberg wrote:
My opinion is that all methods and functions should either:
1. Always return a copy. 2. Always return a view 3. Return a view if possible otherwise raise an exception.
Well, but is copy/view the /only/ invariant worth guaranteeing? I think there is a valid need for functions which ensure other invariants, such as contiguity. There are applications (such as passing pointers to C/Fortran libraries which don't have striding mechanisms but will not modify their inputs) which require contiguous inputs, but where one would rather make a copy only if necessary. My take on this is that we should /document/ clearly what invariants any given function satisfies, but I think the 'always view/always copy' view excludes an important usage case. There may be others beyond contiguity, but that's the one that pops immediately to mind. Cheers, f