Re:Correctness and composability bugs in the Julia ecosystem
by Q6T46nT668w6i3m on Monday May 16, 2022 @09:54AM
(#31397225)
@inbounds is a Base feature.
[ Parent
| on HN ]
Re:Correctness and composability bugs in the Julia ecosystem
by markkitti on Monday May 16, 2022 @10:04AM
(#31397389)
Yes, and it is a perfectly fine feature when applied correctly. It would be incorrect to assume that an `AbstractArray` starts at `1` or `0` which is why the updated example now correctly uses `eachindex`:
https://docs.julialang.org/en/v1/devdocs/boundscheck/#Elidin...
If you want to assume that an array starts at `1` one needs to require an `Array` rather than an `AbstractArray`.
Re:Correctness and composability bugs in the Julia ecosystem
by arksingrad on Monday May 16, 2022 @10:02AM
(#31397347)
@inbounds isn't the problem, it's incorrect usage of it. The poor docstring is absolutely a problem though, you should be iterating over eachindex(A), not 1:length(A).