Why do Lua arrays(tables) start at 1 instead of 0?

后端 未结 8 2160
情歌与酒
情歌与酒 2020-12-12 18:34

I don\'t understand the rationale behind the decision of this part of Lua. Why does indexing start at 1? I have read (as many others did) this great paper. It seems to me a

8条回答
  •  余生分开走
    2020-12-12 18:59

    My understanding is that it's that way just because the authors thought it would be a good way to do it, and after they rolled the language out to the public that decision calcified considerably. (I suspect there would be hell to pay were they to change it today!) I've never seen a particular justification beyond that.

提交回复
热议问题