lua-users home
lua-l archive

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


On 7 Oct 2007, at 13:30, Steve Heller wrote:


On Sun, 7 Oct 2007 06:25:22 -0600, "Patrick Donnelly"
<batrick.donnelly@gmail.com> wrote:


Could be you're expecting pairs() to do the same order every time,
even with the same data input every time.


I don't think that is the problem. I don't rely on the order of
pairs() at all, as far as I know.

I do wonder though: why wouldn't pairs() produce the same order, with
the same data and script(s)?


a) because it's allowed to by the documentation; and,

b) because hash tables use address-based hashing (for keys that are themselves tables), so the order of pairs() depends on where in memory the tables (that are keys) got allocated. That can change either on a whim or, perhaps more likely, when DLLs have been mapped into different places in the address space (thus meaning the holes left for memory allocation are different).

drj