arrays

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

arrays

fschmidt
Administrator
Lua arrays are indexed from 1 to len while most other languages index from 0 to (len-1).  Which do you prefer for Luan?
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture
Reply | Threaded
Open this post in threaded view
|

Re: arrays

Hugo <Nabble>
The problem here is that Lua has a lot of built-in functions that assume arrays and other structures start at index 1. So we would have to keep all functions consistent with whatever value we choose for the first index. Of course my brain is more used to indices ranging from 0 to (len-1), but I can easily work with 1..N as well. I believe 1..N is more intuitive to someone who is looking at a programming language for the first time, but I am not sure this is the kind of user we should target at first place. If we consider tech people in general, than 0..N-1 is probably best. On the other hand, people will certainly search for lua examples on the internet and they will find tons of examples with 1..N. So I don't know what the right answer is. We can talk about this.
Reply | Threaded
Open this post in threaded view
|

Re: arrays

fschmidt
Administrator
We agreed to start with 1.  closing thread
Woe to those who call bad good and good bad -- Isaiah 5:20
Following the Old Testament, not evil modern culture