lua-users home
lua-l archive

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

> Here is a table which from what I can tell is a sequence according to
> the manual yet once you look at the byte code and how the instructions
> are generated you can see why it is not.
> Lets take the example of not a sequence from the manual and adjust it[1]
> [...]
> Lua 5.2.0  Copyright (C) 1994-2011, PUC-Rio
> > do
> >> a={10,20,nil,[3]=30,40}
> >> print(#a)
> >> end
> 4
> Huh so what is wrong? It looks like a table as it has entries for
> 1,2,3 and 4 also the implementation being used tells us it has four
> entries because it is a sequence, or is it?
> [...]
> A little of topic and a corner case I know, but have I missed/misread
> a part of the manual which specifies this behaviour?

Nowhere the manual says the items are processed in a specific order.
Your constructor specifies two different values for 3 (nil and 30), so
Lua is free to set nil and then 30 or 30 and then nil.

-- Roberto