Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
Python syntax in Lisp and Scheme
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="David Mertz, post: 1731518"] |> Isn't it true though that the lambda can only contain a single |> expression and no statements? That seems to limit closures somewhat. |It limits lambdas. It doesn't limit named functions. Unlike lisp, a |Python function definition can be nested within a function call, and the |inner function can access variables in the outer function's closure. I don't really know Lisp, so I could be wrong. But my understanding is that CL has a 'let' special form that works fine within a function definition. In particular, you should be able to define inner functions by binding a name to a lambda, using 'let'. So there's nothing really special about the fact that Python (or Haskell, ML, etc) can nest function definition. Of course, Haskell's 'let' and 'where' are quite wonderful... even better, syntaxwise, than Python's nested 'def's. Yours, David... P.S. On the prior poster's misunderstanding: Lambdas in Python are actually completely general. There is nothing you cannot express using a single expression, even side effects--it just gets ugly doing it. Basically, just like in CL, a list or tuple is a single expression, and it evaluates its elements in predictable left-to-right order... you can work out the rest of the ugly details from that fact. Or you can look at my articles on "FP in Python"--however, my intent in those is NOT to enable obfuscated Python, but to point to actual useful techniques. It's a fine line though. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
Python syntax in Lisp and Scheme
Top