Add local...in syntax

This commit is contained in:
Daniel P H Fox (Roblox) 2025-01-25 17:26:47 -08:00 committed by GitHub
parent d49d29f73a
commit 004b9168ce
Signed by: DevComp
GPG key ID: B5690EEEBB952194

View file

@ -292,6 +292,16 @@ local useState = require("@react")[local]
There is nothing functionally wrong with this, so the proposal doesn't discard this possibility, but it was deemed to have a slightly odd shape compared to other Luau constructs. It could also have an adverse effect on line length.
A `local...in` syntax was considered to make the relationship between identifiers and the indexing operation clearer.
```Lua
local amelia, bethany, carol in nicknames
amelia, bethany, carol in nicknames
```
This was tacitly discarded for now over concerns that the reassignment doesn't seem obvious, and may not make intuitive sense when considered together with `for..in` syntax.
### Implicit key renaming
Renaming identifiers was considered with implicit keys, and should be possible with full backwards compatibility, and support for arbitrary expressions.