-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Currently, for-loops are simple beasts. The syntax is like this:
for NAME ITERATOR:
BODY
I want to change it to:
for NAME1 NAME2 ... in ITERABLE:
BODY
This change would consist of four changes:
- Allowing multiple names for iterating over multiple values at the same time (like with Python's
enumerate()). - Adding
inas a pseudo-keyword to separate the names from the rest. The wordinwould only be treated differently in the head of a for-loop. - For-loops will work with iterables instead of iterators, which means that before the loop, the TOS will be checked for its type, and a certain iterator will be called. For lists, this will be a new version of
in. - This one is less visible: the iterator will no longer get a "hidden" argument, so state will have to be kept in another way (most likely with local variables and the use of
yield).