Why does the type of an index default to Int?



I’m wondering why functions like find return Int instead of say UInt. Indexes, as such, cannot be negative, so they should be unsigned, and the scope of UIntis much larger than an Int (not that we would need an array of length 1.8446744073709552e19). Would it make sense to have some native index type instead of the default Int?


I guess that wouldn’t work for OffsetArrays.


using unsigned ints for indexing would we problematic in index calculations. There are many discussions out there on the Web (for C/C++)

The greater range is (by the way) just a factor of two. This will certainly not be an issue in practice.


Thanks! Good to know this has been thought of before.

I have a feeling that there should be a Venn diagram for “Why and how things are done in C/Matlab/Python” and “Why and how things are done in Julia”. The overlap between the two circles was understandably large at the beginning and diminished some with Julia’s development. I can’t help wonder if radical thoughts, such as a special UInt-y index type, are becoming more and more advantageous, separating those two circles even more apart…


These kind of issues have been covered at length by core developers in old posts either on Discourse or on the former Google Groups. It would indeed be nice to collect them into a FAQ so they are easier to find.