Python syntax in Lisp and Scheme
Björn Lindberg
d95-bli at nada.kth.se
Wed Oct 15 07:37:08 EDT 2003
More information about the Python-list mailing list
Wed Oct 15 07:37:08 EDT 2003
- Previous message (by thread): Python syntax in Lisp and Scheme
- Next message (by thread): Python syntax in Lisp and Scheme
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
mertz at gnosis.cx (David Mertz) writes: > |> Isn't it true though that the lambda can only contain a single > |> expression and no statements? That seems to limit closures somewhat. > > David Eppstein <eppstein at ics.uci.edu> wrote previously: > |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. It is possible (& allowed) to nest defun forms in Lisp, but it does not achieve the same effect as nesting def:s in python. defun will name the function in the global environment, so a nested defun will still define a top-level function. To define a nested function local in scope to the surrounding function, one of FLET or LABELS is used. Björn
- Previous message (by thread): Python syntax in Lisp and Scheme
- Next message (by thread): Python syntax in Lisp and Scheme
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list