Hacker News new | ask | show | jobs
by amalcon 1388 days ago
"Offset-based" is bringing in pointers; that's the thing it's an offset "from". "The beginning of the array" is just a pointer.

I suppose saying that does have an advantage over explicitly talking about pointers, in that the word "pointer" is a piece of jargon that has a lot of baggage. That's just avoiding jargon, though, not really using a different model.

1 comments

No, offset means "measuring from origin", pointers use that language they don't provide it.

The advantages in measuring from origin can accrue to the person choosing to do it, because there are other reasons to do so which aren't satisfying the CPU.

No, offset means "measuring from a defined location". In a computer, the choice of location is more or less arbitrary[0]. If you pick the first element, you get zero indexing. If you pick a space before the first element, you get one indexing. Either one is a pointer, since a pointer is just computer jargon for "a defined location".

Calling that defined location "origin" doesn't suddenly make it not a pointer.

[0]- NUMA and cache effects aside, as they don't matter for this purpose