News for hackers. Stuff that matters.
Re:Python's pre-declared constants are kinda weird by Animats on Wednesday August 26, 2026 @01:46PM (#49453060)
The interior of a for-loop is only a scope, not a closure. In most non-dynamic languages you can't package up the state and hold onto it beyond the life of the loop, which is what closures are for.

Most trouble in this area came from the iteration variable outliving the loop. That's not good when the iteration variable is a pointer. In C, it often is, and at the end of the loop, it points to an invalid address. It was a change to C (when?) to make the iteration variable go out of scope before code after the loop could get at it.

There are no comments on this comment yet.