Samuele Pedroni wrote:
a thunk is like a Smalltalk block, a closure that can rebind the locals and can get arguments ( (line): above) ), and maybe non-local returns ( ^ in Smalltalk): in pseudo-python the above is:
count = 0 defClosureAllowingRebinding _thunk(line): if line.find('Python') >=0: count += 1 print line,
iterclose(open('blah.txt'))(_thunk)
If _rebinding_ is what we're after, then why not go all the way an introduce a rebind operator? Say ':='. Augmented assignment would also become rebinding then (hm, I hear the sound of code breaking in the distance ;-) Add that to MWH's function/class filter patch and you can write: count = 0 def _thunk(line) [iterclose(open('blah.txt'))]: if line.find('Python') >=0: count += 1 # or count := count + 1 print line, Not nice that _thunk needs to be named, but perhaps the function name can become optional: count = 0 def (line) [iterclose(open('blah.txt'))]: if line.find('Python') >=0: count += 1 print line, How's that for a change of direction? ;-) I'm just throwing in an idea, I'm not saying I like this (I don't know yet). Just