[Haskell-cafe] Tail-call optimization

Robert Dockins robdockins at fastmail.fm
Sun Dec 11 19:13:01 EST 2005


On Sunday 11 December 2005 06:54 pm, Joel Reymont wrote:
> Thank you Andrew! Does it have any effect on performance? Is there a
> speed up of any sort from not passing parameters?

Shooting from the hip here, but I doubt it -- AFAIK it all gets lambda-lifted 
in the compiler anyway.

> On Dec 11, 2005, at 11:50 PM, ajb at spamcop.net wrote:
> > Good, but even better is this:
> >
> > writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO ()
> > writeLoop post h ssl
> >   = loop
> >   where
> >     loop = do handle (\e -> post $ NetworkError e) $
> >                 do cmd <- read h ssl
> >                    post $! Cmd $! cmd
> >               loop
> >
> > Avoiding parameter passing can make your code a lot easier to read.
>
> --
> http://wagerlabs.com/
>
>
>
>
>
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe


More information about the Haskell-Cafe mailing list