Hi Andrew,

>       let x = expensiveComputation foo in x + x
>
> I would certainly hope that expensiveComputation wasn't called twice,
> and even though the language doesn't guarantee it, I have already
> written code that assumed it.

I always thought that there is a tiny difference between "let" and "where":
Using "let" "expensiveComputation foo" might be computed twice (depending on 
the compiler?).
But using:

  x + x
  where x = expensiveComputation foo

should compute the value for x only once.
Therefore, I always try to use "where" for common subexpressions.

Please correct me if I'm wrong here.

Cheers,
Jan

_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to