Why don't people like lisp?

Tayss tayss_temp at yahoo.com
Sun Oct 26 10:03:38 EST 2003


Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote in message news:<pan.2003.10.26.09.31.59.388321 at knm.org.pl>...
> > 1  app   = wxPySimpleApp()
> > 2  frame = MainWindow(None, -1, "A window")
> > 3  frame.Show(True)
> > 4  app.MainLoop()
> > 
> > Here, I have to put each line in a magical order.  Deviate the
> > slightest bit, the thing crashes hard.  It is hard to work with this
> > order; wxPython inherited an old design (not wxPython's fault), and
> > it's showing its age.
> > 
> > I'd fix it, but functions don't give me that power.
> 
> Why?

Ok, here I need to make every line execute in order or it crashes. 
The problem is that, like Lisp, Python wants to greedily execute any
function I give it.  So if I try abstracting lines 1, 3 and 4 in a
function, like the following, it will execute line 2 first, crashing
the system:

def make_app(frame):
    app = wxPySimpleApp()  # 1
    frame.Show(True)       # 3
    app.MainLoop()         # 4

# oops, #2 is executed first. game over!
make_app( MainWindow(None, -1, "Sample editor") ) # 2


So I have to somehow wrap up line 2 in something so it won't greedily
execute.  One way is to flash-freeze it in a function, say:
lambda: MainWindow(None, -1, "A window")

or freeze it in a list:
[MainWindow, None, -1, "A window"]

And these are possible solutions.  But it's less readable and frankly
strange to anyone who has to read my code.  It's a weird functional
trick to deal with side-effect ridden code.  When I really just wanted
to make execution work in the right order.  So I likely fail in making
it more readable and maintainable, which is the whole point in doing
this.


> > I need to specify the order of execution,
> 
> What's the problem in specifying the order of execution in functions?

Because in most languages (like Python and Lisp), functions don't give
the right amount of control over side-effects.  They're great when
side-effects don't matter, but once they do, something like macros are
made for that situation.

Now, is this a big deal?  Not really; it doesn't dominate the
advantages of using Python and wxPython.  Just something I noticed. 
But the tool is missing from the programmer's belt -- and whoever
defines a framework is already writing a new language that people must
deal with.




More information about the Python-list mailing list