do...until wisdom needed...

Johann Hibschman johann at physics.berkeley.edu
Tue May 8 14:50:21 EDT 2001


Harry George writes:

> It is a grim learning curve, and it is very easy to forget (e.g., if
> you have to do something else for a month or two).  As Norvig says in
> Paradigms of AI Programming (1992, pg 66):

> "The first step in writing a macro is to regignize that every time you
> write one, you are defining a new language that is just like Lisp
> except for your new macro."

Well, I've never had to maintain ugly lisp code, but if programmers
would stick to Norvig's other rule, namely that macros should be used
to help state the problem, but not to solve it, then this shouldn't
be an issue.  With that advice, macros become extremely useful.

I like being able to write

  (defwindow main :size '(500 500) :title "Hello, world"
    (vbox
      (label "Hello, world" :id 'hello)
      (hbox (button "OK" :id 'ok)
            (button "No"
                    :callback #'(lambda (obj event)
                                 (set-text (get-id 'hello)
                                           "Forget it, then.")))
            (button "Quit"
                    :callback #'(lambda (obj event)
                                  (quit))))))

and have it work.  That much just seems far more readable than the
equivalent python.  It displays the structure.

That being said, python's much better for other things; I'd much
rather write

  v[i,j] = 2.0*x[i] + y[j]

than

  (setf (aref v i j) (+ (* 2.0 (aref x i)) (aref y j)))

If I do too much math in lisp, my brain gets a stack overflow error.


--Johann

-- 
Johann Hibschman                           johann at physics.berkeley.edu



More information about the Python-list mailing list