On 6/22/2011 10:55 AM, Rich Alderson wrote:
From: dwight elvey
Sent: Wednesday, June 22, 2011 6:33 AM
At least LISP is consistant, everything is
postfixed. I just have
a problem debugging LISP because I can't follow the order of
operation as easily ( I suspose one does get used to it ).
"post" =
"after". Lisp is *pre*fixed, i. e., it uses the original
Polish notation, rather than the reverse Polish notation foisted on
us by a calculator manufacturer.[1]
The order of evaluation of a Lisp expression is depth-first, both for
the operator position and for all arguments. Any decent editor will
format the code so that the flow is obvious; for that matter, Lisp has
had pretty-printer functions since the 1960s to take care of that for
you. Lisp is easy to debug.
[1] Yes, I know, RPN came into use before HP started making calculators.
As befits this conversation of RPN, Lisp, and calculators, I thought I'd
mention that at one point a couple of years back I hacked together a
Lisp "compiler" (really a translator) for the HP-48 series. It's just a
small set of RPL programs that translate Lisp code (written using
curly-braces in the place of parens, since that's what the HP-48 uses to
denote lists) into its RPL equivalent. The similarities between the two
languages is so slight (RPL does stand for "Reverse Polish Lisp" after
all) it only took an afternoon of doodling around to get a decent subset
of Lisp working. Really, it made me appreciate how flexible the HP-48
is -- RPL programs can generate other RPL programs!
As a very simple example,
{defun foo {a b} {+ a b}}
becomes a program named "foo" containing:
<< -> a b << a b + >> >>
Never found a good use for it, but it was a fun exercise :).
(If anyone wants the code, I can send it your way...)
- Josh