mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Create syntax-list-comprehensions
This commit is contained in:
parent
e0a9bc191a
commit
b25baf137a
1 changed files with 14 additions and 0 deletions
14
rfcs/syntax-list-comprehensions
Normal file
14
rfcs/syntax-list-comprehensions
Normal file
|
@ -0,0 +1,14 @@
|
|||
## Summary
|
||||
|
||||
Introduce a form of list comprehension using `for var in iterator do` syntax.
|
||||
|
||||
## Motivation
|
||||
|
||||
List comprehensions would bring several benefits and prevent code smell.
|
||||
In Lua you are encouraged to not modify tables during traversal.
|
||||
|
||||
When traversing a table to exclude all the odd numbers you'd be creating a large statement to get rid of them
|
||||
|
||||
## Design
|
||||
|
||||
To solve these problems, I propose a `n for-in-do` expression form that is syntactically similar to a for statement, but lacks terminating `end`.
|
Loading…
Add table
Reference in a new issue