Eliot’s Tips and Tricks

1 based indexes

Lua uses 1 based indexes throughout all its APIs.

i.e. if you have an array of 3 items then they are indexed as 1, 2 and 3 – not 0, 1 and 2.

This is different convention from most other languages like C++, Java and C# so it takes a little getting used to.

Personally I do not find it a big deal when using Iguana – because if I get it wrong the annotations immediately tell me how I screwed up.

The good news is that all the APIs in the Iguana Translator are 1 based. This is much better than the Python APIs in Chameleon which use both 1 and 0 based indexes (ouch). Not much we can do about that without making current users upset – fixing it would break backwards compatibility.

Tagged:

One Comment

  1. Pingback: Will You Share Your Code? - iNTERFACEWARE Inc.

Leave A Comment?