TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Why Python's Lambda is Broken and Can't be Fixed

7 点作者 amarsahinovic超过 12 年前

5 条评论

dragonwriter超过 12 年前
They aren't broken, they work exactly as intended.<p>They are more limited than similar constructs in some other languages, which compels using named functions in situations where in other languages one might use anonymous ones. On balance, this isn't really a big deal.<p>Also, its quite possible to support multistatement lambdas within Python's indentation-sensitive structure; the decision not to do so isn't a result of technical limitations but of aesthetic judgements.
jamesseattle超过 12 年前
I have never used lambda in years of programming Python. If I need a one time function I define a function and use it once. To me it is more readable and readability is one of Python's greatest virtues.
csense超过 12 年前
Javascript's syntax for anonymous functions is awesome.<p>Coffeescript is okay, but it's just a little too terse -- it can sometimes be difficult to figure out what's going on.<p>The lambda syntax is indeed poor; since it forces the function body has to be an expression, it means you have to jump through hoops to get your implementation to be an expression (or give up and define + use a function).
pcote超过 12 年前
The upshot of Python lambdas is they're really convenient in simple situation. It causes trouble when debugging though. Sometimes, I need to stick breakpoints in places that force me to rewrite a lambda as a regular function. The more that happens, the less I like lambdas.
lazzlazzlazz超过 12 年前
Forgive the amateur question: when would one absolutely need to have a function defined inline?
评论 #5185471 未加载