Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New for-loop #1

Open
gvx opened this issue Dec 21, 2013 · 0 comments
Open

New for-loop #1

gvx opened this issue Dec 21, 2013 · 0 comments

Comments

@gvx
Copy link
Owner

gvx commented Dec 21, 2013

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:

  1. Allowing multiple names for iterating over multiple values at the same time (like with Python's enumerate()).
  2. Adding in as a pseudo-keyword to separate the names from the rest. The word in would only be treated differently in the head of a for-loop.
  3. 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.
  4. 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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant