Closures in leu of pointers?

Terry Reedy tjreedy at udel.edu
Sun Jun 30 00:32:46 EDT 2013


On 6/29/2013 5:21 PM, Ian Kelly wrote:
> On Sat, Jun 29, 2013 at 2:53 PM, Terry Reedy <tjreedy at udel.edu> wrote:
>> # The alternative for either program or people is a 1-pass + backtracking
>> process where all understandings are kept provisional until the end of the
>> body and revised as required. 2 passes are simpler.
>
> Or simply an explicit declaration of scope at the beginning of the
> function definition.

One of the reasons I switched to Python was to not have to do that, or 
hardly ever. For valid code, an new declaration is hardly needed. 
Parameters are locals. If the first use of another name binds it (and 
that includes import, class, and def), it is local. If the first use of 
does not bind it, it had better not be local (because if it is, there 
well be an exception). If there are branches, each should be consistent 
with the others. One should only need two readings to understand and fix 
unbound local errors.

-- 
Terry Jan Reedy




More information about the Python-list mailing list