What can you do in LISP that you can't do in Python

James_Althoff at i2.com James_Althoff at i2.com
Tue May 22 17:04:24 EDT 2001


Alex Martelli wrote:
>"Hannah Schroeter" <hannah at schlund.de> wrote in message
>news:9edt7h$ubg$1 at c3po.schlund.de...
>    ...
>> Facit: Smalltalk's blocks, Lisp's and Python's lambdas are just the
same:
>> unevaluated (but possibly compiled!) code, optionally with formal
>> parameters.
>
>...but Python's lambdas are limited to be just *expressions*,
>which IS a serious limitation since so much in Python is in
>terms of *statements*.  A Python *FUNCTION* is not affected
>by this limitation -- *IT* can indeed be ANY piece of compiled
>but unevaluated code, with parameters.  And the only, let's
>say, "limitation", compared to lambda, is that you have to
>give the function a _name_.  That's a pretty modest limitation:-).
>
>
>Alex

I think Alex and I have your basic "second order agreement" on this topic
(having discussed it a few times on this list :-) ) but from my side there
is one other modest difference that you have to consider when you use a
function instead of a lambda.  And that is the issue of defining the
construct "ahead of use" versus "in place" and the "reversal of order" that
this imposes.  This issue stands out a bit more if you have an example with
nesting.  E.g.,

(assuming nested scopes exists -- otherwise it's even more messy)

def doValidation():
    queryForm.validate()
    . . .

def execQuery():
    queryForm.execQuery()
    . . .

def doQuery():
    window.showStatusDuring(
        msg="Validating Query Form ...",
        function=doValidation())
    window.showStatusDuring(
        msg="Getting Results ...",
        function=execQuery())

window.showBusyCursorDuring(function=doQuery)


as contrasted with (in theory):

window.showBusyCursorDuring():
    window.showStatusDuring(msg="Validating Query Form ..."):
        queryForm.validate()
        . . .
    window.showStatusDuring(msg="Getting Results ..."):
        queryForm.execQuery()
        . . .

Jim





More information about the Python-list mailing list