Skip to content

Another inconsistency in for x in range loop #740

Open

Description

@faerot
for i in range(10):
     pass
print(i)

Will print 9 in python, but 10 in javascript, because the loop is unrolled into for (var i=0; i<10; i++)

Activity

  1. JdeH commented on Nov 2, 2020

    @JdeH
    Collaborator

    Easy to solve but will cost some (very limited) performance.
    Changing it may also break some user code.
    Another switch?
    I am in doubt...

  2. faerot commented on Nov 18, 2020

    @faerot
    Author

    IMHO transcrypt is too bugged and fragile in current state anyway, to worry about breaking existing code. Those people who are seriously using it (like me) are kamikaze and already expect things to blow up at any moment :)

    Jokes aside I think consistency with CPython very important and should be rejected only if it adds significant overhead. This is what makes Transcrypt better than RapydScript and alikes. I understand that with transcrypt's design 100% compatability with CPython cannot be achieved, but I think it is a good idea to strive for it everywhere possible.

    To me the most important part of Transcrypt is ability to run the same code both in CPython and in JavaScript, reusing the same code on front-end and on back-end. Minor hiccups like this issue are extremely annoying.

    No need for an extra switch, just fix it! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions