Re: wxPython and macros (was: Why don't people like lisp?

From: Tayss (tayss_temp_at_yahoo.com)
Date: 10/27/03


Date: 27 Oct 2003 03:10:20 -0800

Ok, now being sober...

mike420@ziplip.com wrote:
> Why do you need a macro for that? Why don't you just write
>
> def start_window(name) : # 1
> app = wxPySimpleApp() # 2
> frame = MainWindow(None, -1, name) # 3
> frame.Show(True) # 4
> app.MainLoop() # 5
> return (app, frame) # 6

Remember that we lose this game if lines #2-5 are executed out of
order. The system crashes.

Notice in #1, you used a string ("name") as the parameter. But that's
weird, you'd rather have all of line #3 as the param, not just the
little string part of it. So why can't you do that? The secret is
that strings don't have big side-effects when they execute, but line
#3 does! If you tried calling start_window() with the value of #3,
the call would execute it immediately and the system crashes.

Your example above is sensible, because we don't have the power to do
anything more meaningful. So we're stuck with some trivial function
that does nothing really important. Boa Constructor, the great Python
IDE, pops up three windows of different kinds and names on startup,
but /we/ are stuck with the trivial ability to customize one window's
name.

Sure, we can perform all sorts of functional programming tricks to get
things to execute in the right order as mentioned here:
http://groups.google.com/groups?q=g:thl819841888d&dq=&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=5627c6fa.0310260703.4573b0a%40posting.google.com
but we lose readability, which was the point of this exercise.

Maybe you argue this particular code only occurs once per app; but
there's a good documentation and maintainability advantage of having
stuff done once, and done right. And we talked about closing files
safely with try/finally earlier; that is something that needs to be
done often, and macros are a good way to do it. If I learn #5 should
be in a finally block, I don't want to do a big hunt and replace on my
old apps.

> Conclusion: you don't need macros here.
> Moral: maybe you do not *deserve* macros.

If you think I should be a good boy and go to school only reading the
safe books, getting a spanking when I look at the dangerous ones, well
that's one philosophy of life.

-- Tayssir



Relevant Pages

  • Re: wxPython and macros (was: Why dont people like lisp?
    ... > Why do you need a macro for that? ... you used a string as the parameter. ... the call would execute it immediately and the system crashes. ... Maybe you argue this particular code only occurs once per app; ...
    (comp.lang.lisp)
  • Re: Code wont execute Main Macro Calls - non breaking spaces
    ... I am going to attach my first array which is the same as you have ... So each macro will execute one after the other. ... separated each find string and each replace string for the sake of ...
    (microsoft.public.word.vba.general)
  • Re: Code wont execute Main Macro Calls - non breaking spaces
    ... So each macro will execute one after the other. ... which don't require MatchWildcards and do need clear and replace to be set. ... replace string for the sake of clarification. ...
    (microsoft.public.word.vba.general)
  • Re: Code wont execute Main Macro Calls - non breaking spaces
    ... I am going to attach my first array which is the same as you have ... So each macro will execute one after the other. ... separated each find string and each replace string for the sake of ...
    (microsoft.public.word.vba.general)
  • Re: Storing Formulas - Database
    ... store each of the formulas in a SQL and then load them and have my app ... execute it. ... as a string and not as a result. ... What you need is an EXEC function - a function which can treat a string as a ...
    (microsoft.public.dotnet.general)