Re: [Haskell-cafe] Tail-call optimization

2005-12-11 Thread ajb
G'day all. Quoting Joel Reymont <[EMAIL PROTECTED]>: > Thank you Andrew! Does it have any effect on performance? Yes, however I believe that GHC can perform this transformation automatically at high optimisation levels. Even so, for portability, it's wise not to rely on your implementation perf

Re: [Haskell-cafe] Tail-call optimization

2005-12-11 Thread Robert Dockins
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, 2

Re: [Haskell-cafe] Tail-call optimization

2005-12-11 Thread Joel Reymont
Thank you Andrew! Does it have any effect on performance? Is there a speed up of any sort from not passing parameters? On Dec 11, 2005, at 11:50 PM, [EMAIL PROTECTED] wrote: Good, but even better is this: writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO () writeLoop post h

Re: [Haskell-cafe] Tail-call optimization

2005-12-11 Thread ajb
G'day. Quoting Joel Reymont <[EMAIL PROTECTED]>: > writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO () > writeLoop post h ssl = > do handle (\e -> post $ NetworkError e) $ >do cmd <- read h ssl > post $! Cmd $! cmd > writeLoop post

Re: [Haskell-cafe] Tail-call optimization

2005-12-10 Thread Bulat Ziganshin
Hello Joel, Saturday, December 10, 2005, 11:41:52 PM, you wrote: JR> I always wandered, does ghc do tail-call optimization? ghc does this. but only first of your examples is tail-called. second recursively creates exception hadnlers around your code. just try to textually replace call to writeLo

[Haskell-cafe] Tail-call optimization

2005-12-10 Thread Joel Reymont
I always wandered, does ghc do tail-call optimization? Would it optimize the two variants of the function below or just the first one? --- Proper? writeLoop :: (Event a -> IO ()) -> Handle -> (SSL, BIO, BIO) -> IO () writeLoop post h ssl = do handle (\e -> post $ NetworkError e) $