
Le Thu, 5 Feb 2009 16:12:17 +0000, Mark Dickinson <dickinsm@gmail.com> a écrit :
Yes, good point! That's probably a reason why in some languages loops create local scopes/namespaces. In which case the issue disappears, as 'a' is newly created for each iteration. An incremental value (e.g. a sum) is first defined/initialized outside the loop instead. I takes this as different, but related, issue; because the intention and meaning here is really to have an 'a' for each iteration, matching each item. It is not a value that will evoluate along with the loop cycles, as a sum would: it is not rebinding. Conceptually, 'a' is thus a loop-local name. Maybe a special case for loops, where such "utility short-life names" are common? Not very nice. If "a=..." is allowed even when 'a' exists, and recreates the name, then a distinction with rebinding still holds, in the sense that explicit rebinding is possible (including in non-local scope). But we lose the side-effect of getting a NameError in case the programmer errorneously types an existing name.
Mark
------ la vida e estranya ------ la vida e estranya
participants (1)
-
spir