From 431e81cdff9653cd16c6333bb51c314bd051611d Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Sun, 25 Apr 2021 17:44:03 +0200 Subject: Add FAQ about table iteration order. --- doc/faq.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'doc') diff --git a/doc/faq.html b/doc/faq.html index c7e8e979..6b7dc563 100644 --- a/doc/faq.html +++ b/doc/faq.html @@ -131,6 +131,19 @@ You have to press Ctrl-C twice to get stop your program. That's similar to when it's stuck running inside a C function under the Lua interpreter. +
+
Q: Table iteration with pairs() does not result in the same order?
+
The order of table iteration is explicitly undefined by +the Lua language standard.
+Different Lua implementations or versions may use different orders for +otherwise identical tables. Different ways of constructing a table may +result in different orders, too.
+Due to improved VM security, LuaJIT 2.1 may even use a different order +on separate VM invocations or when string keys are newly interned.

+If your program relies on a deterministic order, it has a bug. Rewrite it, +so it doesn't rely on the key order. Or sort the table keys, if you must. +
+
Q: Can Lua code be safely sandboxed?
-- cgit v1.2.1