Hacker News new | past | comments | ask | show | jobs | submit login

An equivalent construct works differently (and one would say in a way that is less error-prone) in other languages.

For instance the behaviour of a Python loop varies drastically depending on the size of the iteration:

     def loop(n):
         for i in range(n):
             pass
         print(i)

     loop(10) # 9
     loop(0)
     Traceback (most recent call last):
       File "<stdin>", line 1, in <module>
       File "<stdin>", line 4, in loop
     UnboundLocalError: local variable 'i' referenced before assignment
That Python works this way is specific to Python. And a language which doesn't have the issues this implies would be "getting it right", in the sense of avoiding sharp corners and edge cases.



I see, it makes sense to force people to use different variables for iteration in that case because it can easily trip inexperienced developers up.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: