No, I /really would/ like to be able to write:
foo.on_click(lambda: x += 1)
The language not supporting this (when most others do) is just silly.
No, I /really would/ like to be able to write:
foo.on_click(lambda: x += 1)
The language not supporting this (when most others do) is just silly.
Mutation in lambdas is not compatible with your complaint about "inadequate support for high-level functional programming", as it goes against the principles of FP.
You can't do that in Haskell either, and any FP purist would blanch at a statement like that.
Obviously you've never met State and/or lens then.
Yes, you can do it -- and no, I never said it should follow pure FP principles.
What about us FP pragmatists? Also in some domains I'd argue being a FP purist is the most pragmatic option.
foo.on_click(lambda:x func(x, whatever)) lambda x: func(x, whatever)
In fact, if x is an object that stores a mutable numeric cell, you could even do a mutating: lambda x: x.add(1)
Mutation isn't prohibited in Python lambdas, statements (including assignments, which are statements rather than expressions in Python), however, are.Mutating variables in a lambda is something abhorred in many functional languages.
foo.on_click(partial(q.append, foo))
The nice thing about ``append`` is it's atomic (for builtins).Or maybe what's in the queue gets written to a permanent log and ``x`` is a query of that log, a la Datomic.
I guess this is another "simplification" along with the magic scoping model (I want perl's my/ES6's let damnit sulk) ...