From b25baf137a8e52aa115af4a679d8f924a083b4c7 Mon Sep 17 00:00:00 2001 From: James Napora <85808999+TheGreatSageEqualToHeaven@users.noreply.github.com> Date: Sun, 13 Feb 2022 16:19:34 -0800 Subject: [PATCH] Create syntax-list-comprehensions --- rfcs/syntax-list-comprehensions | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 rfcs/syntax-list-comprehensions diff --git a/rfcs/syntax-list-comprehensions b/rfcs/syntax-list-comprehensions new file mode 100644 index 00000000..cdd3388e --- /dev/null +++ b/rfcs/syntax-list-comprehensions @@ -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`.