From 82a8c64b39651b9da6c5e03f523ad28e2bf8d2ee Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Wed, 21 Apr 2021 09:25:04 -0700 Subject: [PATCH] Update compatibility.md Call out the upcoming change to `print` and slightly reword a couple of rows. Also add a list of differences from 5.x that was previously requested (the list is likely incomplete) --- docs/_pages/compatibility.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/docs/_pages/compatibility.md b/docs/_pages/compatibility.md index 8482a7b0..b53f3d94 100644 --- a/docs/_pages/compatibility.md +++ b/docs/_pages/compatibility.md @@ -47,10 +47,11 @@ Sandboxing challenges are [covered in the dedicated section](sandbox). | feature | status | notes | |---------|--------|------| -| yieldable pcall and metamethods | ✔️/❌ | pcall/xpcall supports yielding but metamethods don't | +| yieldable pcall/xpcall | ✔️ | | +| yieldable metamethods | ❌ | significant performance implications | | ephemeron tables | ❌ | this complicates the garbage collector esp. for large weak tables | | emergency garbage collector | ❌ | Luau runs in environments where handling memory exhaustion in emergency situations is not tenable | -| goto statement | ❌ | this complicates the compiler due to handling of locals and doesn't address a significant need | +| goto statement | ❌ | this complicates the compiler, makes control flow unstructured and doesn't address a significant need | | finalizers for tables | ❌ | no `__gc` support due to sandboxing and performance/complexity | | no more fenv for threads or functions | 😞 | we love this, but it breaks compatibility | | tables honor the `__len` metamethod | ❌ | performance implications, no strong use cases @@ -110,9 +111,16 @@ Floor division is less harmful, but it's used rarely enough that `math.floor(a/b | `utf8` library accepts codepoints up to 2^31 | 🤷‍♀️ | no strong use cases | | The use of the `__lt` metamethod to emulate `__le` has been removed | 😞 | breaks compatibility and doesn't seem very interesting otherwise | | When finalizing objects, Lua will call `__gc` metamethods that are not functions | ❌ | no `__gc` support due to sandboxing and performance/complexity | -| The function print calls `__tostring` instead of tostring to format its arguments. | 🔜 | | +| The function print calls `__tostring` instead of tostring to format its arguments. | ✔️ | | | By default, the decoding functions in the utf8 library do not accept surrogates. | 😞 | breaks compatibility and doesn't seem very interesting otherwise | Lua has a beautiful syntax and frankly we're disappointed in the ``/`` which takes away from that beauty. Taking syntax aside, `` isn't very useful in Luau - its dominant use case is for code that works with external resources like files or sockets, but we don't provide such APIs - and has a very large complexity cost, evidences by a lot of bug fixes since the initial implementation in 5.4 work versions. `` in Luau doesn't matter for performance - our multi-pass compiler is already able to analyze the usage of the variable to know if it's modified or not and extract all performance gains from it - so the only use here is for code readability, where the `` syntax is... suboptimal. If we do end up introducing const variables, it would be through a `const var = value` syntax, which is backwards compatible through a context-sensitive keyword similar to `type`. + +## Lua 5.x differences + +We have a few behavior deviations from Lua 5.x that come from either a different implementation, or our desire to clean up small inconsistencies in the language/libraries: + +* Order of table assignment in table literals follows program order in mixed tables (Lua 5.x assigns array elements first in some cases) +* Equality comparisons call `__eq` metamethod even when objects are rawequal (which matches other metamethods like `<=` and facilitates NaN checking)