Interesting read, thanks! I guess I'll hold off implementing this until 0.5 lands, then.
// T On Monday, January 25, 2016 at 7:56:15 PM UTC+1, Yichao Yu wrote: > > On Mon, Jan 25, 2016 at 1:49 PM, Tomas Lycken <[email protected] > <javascript:>> wrote: > > On e.g. Arrays, I can index with @inbounds to avoid bounds checking. In > my > > own custom type, which also implements getindex, what is the correct way > of > > leveraging inbounds? > > > > For example, I have code now that looks something like this: > > > > function getindex(A::MyCustomArray, x) > > ix = clamp(round(Int, x), 1, length(A)) # yes, clamp makes sense in > this > > case > > ... > > > > but if the caller has specified @inbounds, I want to avoid the clamp and > > just set ix = round(Int, x). What would be the correct way to express > that? > > No automatic way to do this on 0.4 AFAIK. For 0.5-dev see > https://github.com/JuliaLang/julia/pull/14474 > > > > > // T >
