Hi Tim,

I should have known you already have a (very elegant) solution in your 
pocket. :-) I really like your proposed first:last syntax!

Concerning Base._length, I was rather thinking about something for the 
average user to use instead of length. For everyday 
use, length(linearindices(A)) is just too unwieldy, IMHO.


Cheers,

Oliver


On Tuesday, July 26, 2016 at 9:21:27 AM UTC+2, Oliver Schulz wrote:
>
> I was reading up on the new arrays with custom indices in 0.5. Now that 
> array indices do not implicitly start with one, what's the generic 
> replacement for index ranges like
>
> A[2:end-1]
>
> Will there by something like
>
> A[start+1:end-1]
>
> or so?
>
> Also, since for safety reasons length(A) is now supposed to throw an error 
> for custom-indexed Arrays (for safety, to prevent 1:length[A]), the current 
> recommendation (http://docs.julialang.org/en/latest/devdocs/offset-arrays/) 
> is to use
>
> length(linearindices(A))
>
> instead of length() in generic code. This strikes me as very lengthy 
> indeed (pardon the pun) and will make code less readable - how about a new 
> length function like
>
> Base.len(A) = length(linearindices(A))
>
> or similar? If there's no "official" replacement for length in Base, I 
> suspect that packages will add their own internal version of it at some 
> point. Also, people might get tempted to continue using length() out of 
> laziness (if there's no short replacement) - resulting in code that fails 
> for the new arrays.
>
>
>

Reply via email to