This looks interesting... one of my pet peeves is writing imperative code in functional languages like Lisp or OCaml. For example, hand-written lexers and parsers are heavily stateful and don't really benefit from the functional style, even though they are pure functions from the outside.
It just feels and reads a lot worse than doing it in say Python. So you could make a program clearer by writing the functional parts in one syntax and the imperative parts in another syntax.
Have you ever used parser combinators? They're the absolute best way of parsing anything that I've ever tried. Parsing anything in Python definitely is much worse.
Also, I'd like second the other posters suggestion that most Lisps have many ways of writing imperative code and that it really is no different than your average C-like in that respect.
I'll take another look at parser combinators. I keep hearing people talking about them, but I had never seen them used for anything big. Now that I check again, I see that the ShellCheck lexer/parser in Haskell is written with Parsec, and it seems to do a pretty good job, and has good places to insert error messages and so forth.
Do you have any other examples of a production quality parser done with parser combinators?
The Lisp parser I was thinking about was Julia, which is bootstrapped in femtolisp. It looks like straight imperative code in Lisp to me.
I'm mainly concerned large parsers, like bash, Julia, Ruby, or C. You can write a small parser with any technology. FWIW I have a lot of posts about parsing here, towards the beginning of the blog: http://www.oilshell.org/blog/
EDIT: What's the benefit of parser combinators over recursive descent in Python or say Java? Is it just that it's point-free so you don't have to explicitly pass the input around?
I suppose if I saw the same parser written in parser combinators and recursive descent it would be easy to tell what the benefit is, if any.
Just in case anyone interested in Lisp reads this, Lisp (short for Common Lisp) is not a functional language. You can write imperative programs. You can write object oriented programs. You can write functional programs. You can write programs that are all 3 at the same time. Lisp is designed to handle whatever you can think up. Not sure what this guy is talking about. Especially since python forces you to constantly create temporary throw away variables without being able to be explicit about their scope.
parsing doesn't benefit from a functional style?
the expressiveness and clarity of parser combinators in haskell are one of the languages selling points.
It just feels and reads a lot worse than doing it in say Python. So you could make a program clearer by writing the functional parts in one syntax and the imperative parts in another syntax.