diff options
| author | Mike Pall <mike> | 2021-04-25 17:44:03 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2021-04-25 17:44:03 +0200 |
| commit | 431e81cdff9653cd16c6333bb51c314bd051611d (patch) | |
| tree | be94adb99dd56149c60848f7dbf75d0403ef510b | |
| parent | 33e3f4badfde8cd9c202cedd1f4ed9275bc92e7d (diff) | |
| download | luajit-431e81cdff9653cd16c6333bb51c314bd051611d.tar.gz luajit-431e81cdff9653cd16c6333bb51c314bd051611d.tar.bz2 luajit-431e81cdff9653cd16c6333bb51c314bd051611d.zip | |
Add FAQ about table iteration order.
| -rw-r--r-- | doc/faq.html | 13 |
1 files changed, 13 insertions, 0 deletions
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 | |||
| 131 | to when it's stuck running inside a C function under the Lua interpreter.</dd> | 131 | to when it's stuck running inside a C function under the Lua interpreter.</dd> |
| 132 | </dl> | 132 | </dl> |
| 133 | 133 | ||
| 134 | <dl id="order"> | ||
| 135 | <dt>Q: Table iteration with <tt>pairs()</tt> does not result in the same order?</dt> | ||
| 136 | <dd>The order of table iteration is explicitly <b>undefined</b> by | ||
| 137 | the Lua language standard.<br> | ||
| 138 | Different Lua implementations or versions may use different orders for | ||
| 139 | otherwise identical tables. Different ways of constructing a table may | ||
| 140 | result in different orders, too.<br> | ||
| 141 | Due to improved VM security, LuaJIT 2.1 may even use a different order | ||
| 142 | on separate VM invocations or when string keys are newly interned.<br><br> | ||
| 143 | If your program relies on a deterministic order, it has a bug. Rewrite it, | ||
| 144 | so it doesn't rely on the key order. Or sort the table keys, if you must. | ||
| 145 | </dl> | ||
| 146 | |||
| 134 | <dl id="sandbox"> | 147 | <dl id="sandbox"> |
| 135 | <dt>Q: Can Lua code be safely sandboxed?</dt> | 148 | <dt>Q: Can Lua code be safely sandboxed?</dt> |
| 136 | <dd> | 149 | <dd> |
