
On 06/11/09 09:03, Deniz Dogan wrote:
2009/11/6 Keith Sheppard
: Also, an nice way to check how evaluation works in ghci is to do something like:
if False && error "error here" then "it's true" else "it's false"
This expression will evaluate as "it's false" without any "error here" error message appearing
On Thu, Nov 5, 2009 at 9:05 PM, Nathan M. Holden
wrote: If you have an if statement like
if (a&&b) then fun else fun'
and a is false, does GHC actually bother to check b?
Note that Haskell is far from the only programming language that is smart about this. I actually can't think of a single programming language implementation that I know of which isn't this smart...
For what it's worth, Haskell (and others) is smart about ORs as well. In (x || y), y will only be evaluated if x is False.
IIRC Pascal isn't "smart" about it. /M -- Magnus Therning (OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe