button.onClick(lambda bar, fram: baz(foo(bar, fram)))
The problem with embedding procedure definitions within parameter lists is indentation. Languages such as JavaScript or Ruby use explicit syntax for indentation, which allows a degree of flexibility in how procedure literals are defined. Python uses only whitespace, so trying to extend the grammar to support arbitrary procedure literals would be very difficult (according to Guido).Anyway, I'm familiar with why Guido doesn't want them, and I totally respect it, and I write 99% of my personal code in python, so I clearly don't think it's a huge deal. It's just something I wish python did have, is all.
Nothing other than an if statement, a goto, and some basic arithmetic is needed in a programming language. It's all syntactic sugar. I agree that such a construct would be useful. However, it's more about if it's worth complicating the language over. I don't necessarily know how complex that would make things, but I can definitely see that a case can be made that it would be more trouble than it's worth considering the way indentation is handled.
class Somebutton(Button):
def onClick(self):
.....
def onSomethingElse(self):
.....
only one line of overhead (class line). And I'm pretty sure you can hack __dict__ in init, or use metaclasses so that the events are chained automatically, even without calling `Button.onClick(self)`. You can construct / add the object to it's container the same way (Somebutton(), instead of Button())In my experience (mostly JS and AS) they rather usually lead to little pieces of logic scattered all over the place and insufficient decoupling.
Sometimes, for reasons of style and clarity, I want to define a function inline, but python doesn't allow me to. It forces me to do:
When in some cases, I would like to express it as: So I get that it's never necessary, but I find it sometimes limiting as an author who cares strongly about how his code is organized.