r/programming • • Mar 14 '09

Hello Haskell, Goodbye Lisp

http://www.newartisans.com/2009/03/hello-haskell-goodbye-lisp.html
48 Upvotes

80 comments sorted by

View all comments

Show parent comment

9

u/shrughes Mar 14 '09 edited Mar 14 '09

Making new control structures is the same thing as skipping parameter evaluation.

Suppose I wanted to write a while loop in Haskell. (I wouldn't, except as a totally contrived example.):

while :: IO Bool -> IO () -> IO ()
while test m = do
  { b <- test
  ; if b
    then do { m ; while test m }
    else return ()
  }

This behaves just like a C while loop. It's not like you need laziness for such a thing -- you could do something similar in C#, using Func<bool> and Action in place of IO Bool and IO (), except that if you used recursion, you'd overflow the stack.

The laziness only wins you a slightly nicer syntax.