News for hackers. Stuff that matters.
Re:Edsger Dijkstra's note on starting array indices at 0 (pd... by wzdd on Tuesday June 21, 2011 @08:26PM (#2681019)
48 hours writing a game in Lua (which indexes from 1) drives this home: in tile-based games, converting screen co-ordinates into tile co-ordinates results in zero-based indices. My graphics routines were full of +1s and -1s as a result.

Generally any time array indexing intersects with mathematics you are going to get the same issue.

That combined with the fact that, in Lua, sometable[0] doesn't produce a not-present exception (it returns 'nil') resulted in a lot of unnecessary cursing.

Re:Edsger Dijkstra's note on starting array indices at 0 (pd... by chalst on Wednesday June 22, 2011 @03:01AM (#2682074)
You can use a metatable to change this behaviour, either by reindexing, or by returning an error on lookups to values not in the range 1 to #table.