Why Python Lambda is Broken and Can't be Fixed

By Xah Lee. Date: . Last updated: .

You have to contend with Python's broken notion of lambda but other than that it's not really that different [from teaching computer science using Scheme Lisp].

From [Hal Abelson Q&A By Peter Seibel. At http://www.codequarterly.com/2011/hal-abelson/ , accessed on 2013-01-03 ]

Hal Abelson is one of the author of the most famous computer science textbook Structure and Interpretation of Computer Programs in the 1990s.

Python's broken lambda… Indeed.

Why Python Lambda is Broken and Can't be Fixed

Here's why Python's lambda is broken and can't be fixed.

Syntactically, lambda is a way to define a function, which may be arbitrarily complex. But due to Python syntax choice of indentation, so full lambda will need indentation, and thus cannot be a inline argument to other functions.

The other issue is that Guido doesn't like functional programing.

So, what we have here is a syntax-induced limitation on the language's semantics.

The take-away of this is that, syntax is fundamental in programing languages. And, syntax is the MOST important part of language. It influences thought and what sort of program comes out.

Lisp wouldn't have developed its macros if its syntax isn't mostly regularly nested parens. XML wouldn't have developed many of its processing tools and tree-walkers if its syntax isn't nested tree. You wouldn't chain commands if unix shell doesn't have the pipe syntax.

See also: What Languages to Hate

Xah Talk Show 2021-05-28 Why Python Lambda is Broken and Can't be Fixed