3 ms·
Julia's docs say that it supports "Julia supports arrays with arbitrary indices": https://docs.julialang.org/en/v1/devdocs/offset-arrays/ https://docs.julialang
by fault1 5y ago
Julia's docs say that it supports "Julia supports arrays with arbitrary indices":
https://docs.julialang.org/en/v1/devdocs/offset-arrays/ https://docs.julialang.org/en/v1/devdocs/offset-arrays/
So let's break that down.
The base standard library and "idiomatic" Julia are both largely written without the assumption of 1-based indexing, instead dispatching to what you think about as an array-oriented dsl, which is this interface: https://docs.julialang.org/en/v1/manual/interfaces/#man-interface-array https://docs.julialang.org/en/v1/manual/interfaces/#man-inte...
It is very normal in Julia to implement such interfaces to do what you want. Julia uses these types of internal interfaces with multimethods in lieu of a lot of compiler intrinsics.
So I would say Julia and Fortran have different implementations of arbitrary indexing.
They are both oriented around core design features of each respective language.
- shele 5y agoYes, Julia does support arbitrary indexing because base functions are written in terms of `firstindex`, `eachindex` and `lastindex` etc. One can see it in the implementation of `filter!` for example https://github.com/JuliaLang/julia/blob/ab4e036b9209967b427345f99fb27a551c9aff60/base/array.jl#L2554 https://github.com/JuliaLang/julia/blob/ab4e036b9209967b4273... :