Transcrypt icon indicating copy to clipboard operation
Transcrypt copied to clipboard

Another inconsistency in for x in range loop

Open faerot opened this issue 5 years ago • 2 comments

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++)

faerot avatar Jun 23 '20 08:06 faerot

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

JdeH avatar Nov 02 '20 08:11 JdeH

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! :)

faerot avatar Nov 18 '20 15:11 faerot