lua-users home
lua-l archive

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


Exactly!!

On Jul 6, 2013, at 5:20 AM, Rena <hyperhacker@gmail.com> wrote:

It does seem awfully strange to me: Lua's strings can contain any byte, because they store the length separately from the string data. This is generally considered a good thing, especially compared to C strings - it takes length lookup from O(n) to O(1) and allows them to contain arbitrary binary data. Yet Lua's arrays don't have this same feature, and instead use the C-string method of a magic terminating value that can't appear anywhere in the array, which limits what they can store. (Though I assume length lookup is still O(1) in this case!) And as a "bonus" it makes the # operator's behaviour somewhat strange as well - not always very reliable or useful, and apparently rather confusing to some people.