Skip to content

Cannot use expressions as iterables in loop #631

Open

Description

@faerot

in python you can use
for self.attr in list
this translates to for (var self.attr of list) which gives syntax error.
Need to generate temporary variable for iteration and assign it to attribute inside loop on first line:

for (var temp_iter of list) {
    self.attr = temp_iter
    ...

in case where iterable is just an identifier, we can skip this extra assignment.

Activity

  1. AlexECX commented on May 12, 2019

    @AlexECX

    Another way could be to not write var when an object attribute accessor is used (or whatever Object.attribute is called). for SomeObject.attr in list would translate to for (SomeObject.attr of list).
    Don't know which one is easier to implement.

  2. self-assigned this
    on Aug 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions