3 ms·
Do not add any more fuel to the flame and instead use 2-based indexing: https://github.com/simonster/TwoBasedIndexing.jl https://github.com/simonster/TwoBasedIn
by lifthrasiir 6y ago
Do not add any more fuel to the flame and instead use 2-based indexing: https://github.com/simonster/TwoBasedIndexing.jl https://github.com/simonster/TwoBasedIndexing.jl
Seriously, the exact value of the lower bound for indexing doesn't matter here (some algorithms are best described with the lower bound other than 0 or 1, for example). The fixed or preferred lower bound is the real problem. Any argument for/against 0-based and 1-based indexing tends to gloss over the real problem because those arguments only exist to make some languages look better than other languages. As we move away from forced explicit indexing (e.g. arr.first() or foreach instead of arr[$LBOUND] or `for (i=$LBOUND; ...)`), it becomes clear that there is no such thing like the preferred lower bound for sequences at all.
- epage 6y ago> Do not add any more fuel to the flame and instead use 2-based indexing: https://github.com/simonster/TwoBasedIndexing.jl https://github.com/simonster/TwoBasedIndexing.jl This reminds me of my last company where the answer to the 2 vs 4 space debate was 3 spaces.
- corysama 6y ago“Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.” — Stan Kelly-Bootle
- ufo 6y agoFun fact: Hisham, the author of the blog post we're discussing is a notorious user of 3 space indentation. It actually works quite well in Lua, where blocks are terminated by the "end" keyword. Still sacrilegious if you ask me though :)