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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4