[Haskell-cafe] Re: Is lazyness make big difference?

Gleb gleb.alexeev at gmail.com
Thu Feb 15 07:51:13 EST 2007


Nick wrote:
> 
>     /* Lazily compute the logger. The computation will not
>         start running until the value of 'logger' is actually requested. */
>     var logger = lazy({ Logging.getLogger() })
> 
>     /* This will start the computation */
>     logger.debug("medved")
> 
>     /* No delay to compute the logger again, as it has already been
>     calculated */
>     logger.debug("preved")
> 
It seems you miss the point here: not only logger should be lazy, but 
all calls to logger's methods:

logger.debug(formatLongMessage(args)); // formatLongMessage should not
                                        // waste CPU cycles if debug
                                        // logging is off





More information about the Haskell-Cafe mailing list