Functional programming in Python
Tue, 22 May 2001 17:51:58 +0300
I realize this is a topic where it would be very easy to start a flame
war, but hopefully we can avoid that.
Paul Hudak wrote:
> Why not have your tool generate layout-less code? Surely that would be
> easier to program, and be less error prone.
The tool in question is Happy, and the error materialized as an
between the tool-generated parser code and the hand-written code in
So no, this was not an option since the tool is not written by me, and
my current capabilities in Haskell I could not even fix it. On the other
the bug is easy to work around, and it might even be fixed in newer
> Yes, but the layout is not ENFORCED. I programmed in Lisp for many
> years before switching to Haskell, and a common error is something like
> > (let ((a 0)
> > (b 1)
> > (+ a b)))
> In this case the error is relatively easy to spot, but in denser code it
> can be very subtle. So in fact using layout in Lisp can imply a
> semantics that is simply wrong.
Maybe I did not express my point clearly. What I was trying to say was
because of the syntax, it is very easy for M-C-q in Emacs to convert
(let ((a 0)
(+ a b)))
which brings the layout of the source code to agreement with how it is
by the compiler/interpreter. So it is easy for me to enforce the layout.
This is not so much of an issue when you are writing the code in the
but I find it a pain to have to adjust indentation when I move bits of
in an evolving program. If there is good support for that, then I'll
just shut up
an start using it. After all, I have only been using Haskell for a very
period of time.