4 ms·
I found it devastating that there are no distinct agreed-upon words denoting zero- and one-based addressing. Initially I thought that the word "index" clearly d
by myfonj 2y ago
I found it devastating that there are no distinct agreed-upon words denoting zero- and one-based addressing. Initially I thought that the word "index" clearly denotes zero-base, and for one-base there is "order", "position", "rank" or some other word, but after rather painful and humiliating research I stood corrected. ("Index" is really used in both meanings, and without prior knowledge of the context, there is really no way to tell what base it refers to.)
So to be clear, we have to tediously specify "z e r o - b a s e d " or "o n e - b a s e d" every single time to avoid confusion. (Is there a chance for creating some new, terser consensus here?)
- aero142 2y agoI humbly submit '1ndex' and 'ind0x', or '1dx' and 'i0x'.
- pixl97 2y agoWhile most people ran screaming from programming assembly aero142 thought it was a rather swell idea.
- tdeck 2y agoFrankly it's no worse than "mebibyte".
- wasabi991011 2y agoPronounced "one-dex" and "in-dox"?
- Rygian 2y agoI think that "zero-based" and "one-based" expressions are the distinct agreed-upon "words" and they are terse enough. I can suggest "z8d" and "o7d" otherwise. (/jk)
- xandrius 2y agoI always thought: - Offset: 0-based - Index: 1-based
- naasking 2y agoIndex is ambiguous. I think "Offset" and "Itemized".
- xandrius 2y agoIndex is like your finger, you count from 1, right?
- moefh 2y agoThat sounds reasonable at first, but humans are messy and so the distinction is not always clear. For example, in music we use numbers for the notes of a scale (G is the 5th of C, because in the C major scale: C=1, D=2, E=3, F=4, G=5, A=6, B=7). The numbers are clearly indices for the notes of the scale. But we often think of stuff like: what's the 3rd of the 5th -- that is, get the note at the 5th position (G in our example) and then get the 3rd of that note (the 3rd of G is B). But note that B is the 7th of C major, not the 8th you'd get from adding 5 and 3. The problem, of course, is that we ended up using the numbers as offsets, even though they started as indices.
- xandrius 2y agoYeah, because the scale is an index (e.gm A=6) but the operations are offsets in that case. Because if you moved from G/5 to B/7 that is clearly 2.
- moefh 2y agoYes, that's the point: the numbers are used as both indices and offsets. To any musician or music student, moving from G to B is "going up a (major) third", even though it's obviously going up by 2 notes. The name of that offset ("interval" in music speak) is "third", even though it has a distance of 2 notes. My point (more generally) is that even though it looks reasonable to make indices start from 1 and offsets from 0, in practice these things can get mixed together. It's not reasonable to get people to use two different numbers for what they see as the same thing (because their use got mixed).
- pansa2 2y agoAFAIK "offset" (i.e. from the beginning of the array/file/etc) is commonly used to indicate a zero-based index.
- TOGoS 2y agoI like this. I feel like "offset" hints at the reason for starting at 0. "How far do you have to offset your feet (from the beginning of whatever space we're talking about) before you're touching the thing in question?" If it's the first thing, you don't have to move at all, so zero offset
- TOGoS 2y agoOf course you could also "offset your feet" until they're past the end of the last thing, and then you've counted the number of things. But the offset of the thing itself (as opposed to that of your feet) could be considered zero, assuming the natural position of the thing is for its left edge to be at the left edge of the space. But maybe its natural position is to be centered at x=0 and it had to be moved by 0.5 for the left edges to line up, in which case see my other comment. In any case, I think the argument over 0 or 1 or 0.5-based indexing can be resolved just by being clear about what it is you're counting.
- otikik 2y agoZerodex and onedex?
- weinzierl 2y agoI don't think "index" by itself should imply any starting value. After all many induces start at higher numbers and then you'd have to invent words for 2-based, 3-based and so on as well.
- inkcapmushroom 2y agoMaybe we can call it 0ndex and 1ndex. Really rolls off the tongue.
- scoofy 2y agoI mean, I think "ordinal" and "zordinal" would work.
- xeonmc 2y agoor Ordinal and Cardinal, meaning ordering and counting respectively
- lupire 2y ago"offset" and "ordinal".
- zajio1am 2y agoOrdinals in math also start at zero. It is just common people accepted zero for cardinals and but not (yet) for ordinals.