lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Sunday 28 October 2007, David Given wrote:
> The problem is that when you deal with 1-based arrays, offsets and indices
> now become *different*. With 0-based arrays, they're the same.

this is one of the very few concrete arguments one way or the other... and a 
strong one, IMO.

> The end result is that all my string handling code has to be full of -1s.
> Ironing out all the off-by-one errors was a pain.

the problem is that no matter which one you choose, you'll have a lot of 
opportunities for off-by-one errors.  the difference is that starting on 0 
the errors are mostly on 'simple' loops ('noob errors'); and starting on 1 
it's on slightly more complex code (on your case, index additions)


-- 
Javier

Attachment: pgp1tRwmZRjCv.pgp
Description: PGP signature