You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: luau/getting-started/compatibility.md
+17-4Lines changed: 17 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -104,10 +104,10 @@ If integers are taken out of the equation, bitwise operators make less sense, as
104
104
105
105
| feature | status | notes |
106
106
|--|--|--|
107
-
| new generational mode for garbage collection | π | we're working on gc optimizations and generational mode is on our radar
107
+
| new generational mode for garbage collection | π€·ββοΈ | we've implemented other optimizations to garbage collection
108
108
| to-be-closed variables | β | the syntax is inconsistent with how we'd like to do attributes long-term; no strong use cases in our domain |
109
-
| const variables | β |while there's some demand for const variables, we'd never adopt this syntax |
110
-
| new implementation for math.random | βοΈ | our RNG is based on PCG, unlike Lua 5.4 which uses Xoroshiro |
109
+
| const variables | β |available through `const var = value` syntax |
110
+
| new implementation for `math.random`| βοΈ | our RNG is based on PCG, unlike Lua 5.4 which uses Xoroshiro |
111
111
| optional `init` argument to `string.gmatch`| π€·ββοΈ | no strong use cases |
112
112
| new functions `lua_resetthread` and `coroutine.close`| βοΈ ||
113
113
| coercions string-to-number moved to the string library | π | we love this, but it breaks compatibility |
@@ -120,7 +120,20 @@ If integers are taken out of the equation, bitwise operators make less sense, as
120
120
121
121
Taking syntax aside (which doesn't feel idiomatic or beautiful), `<close>` 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. `<const>` 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 `<const>` syntax is... suboptimal.
122
122
123
-
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`. That said, there's ambiguity wrt whether `const` should simply behave like a read-only variable, ala JavaScript, or if it should represent a stronger contract, for example by limiting the expressions on the right hand side to ones compiler can evaluate ahead of time, or by freezing table values and thus guaranteeing immutability.
123
+
Const variables are available in Luau through a `const var = value` syntax, which is backwards compatible through a context-sensitive keyword (similar to `type`).
124
+
125
+
## Lua 5.5
126
+
127
+
| feature | status | notes |
128
+
|--|--|--|
129
+
| declarations for global variables | β | no strong use cases, mistakes are caught by typechecker |
130
+
| named vararg tables | π€·ββοΈ ||
131
+
| for-loop variables are read only | β | breaks compatibility |
132
+
| floats are printed in decimal with enough digits to be read back correctly | βοΈ ||
0 commit comments