[Python-Dev] accumulator display syntax

Samuele Pedroni pedronis at bluewin.ch
Tue Oct 21 18:49:23 EDT 2003


At 00:43 22.10.2003 +0200, Samuele Pedroni wrote:

>this is a bit OT and too late, but given that our closed over variables 
>are read-only, I'm wondering whether, having a 2nd chance, using cells and 
>following mutations in the enclosing scopes is really worth it, we kind of 
>mimic Scheme and relatives but there outer scope variables are also 
>rebindable. Maybe copying semantics not using cells for our closures would 
>not be too insane, and people would not be burnt by trying things like this:
>
>for msg in msgs:
>   def onClick(e):
>     print msg
>   panel.append(Button(msg,onClick=onClick))
>
>which obviously doesn't do what one could expect today. OTOH as for 
>general mutability, using a mutable object (list,...) would allow for 
>mutability when one really need it (rarely).

of course OTOH cells make it easier to cope with recursive references:

def g():
   def f(x):
     ... f refers to f ...
   return f

but this seem more an implementation detail, although not using cells would 
make this rather
trickier to support. 




More information about the Python-Dev mailing list