
On Saturday 22 September 2007 10:58:49 Neil Mitchell wrote:
Hi
f = f
and then try to evaluate 'f' in GHCi, as one would expect, the interpreter never returns an answer.
The funny thing is that, while it is stuck in an infinite loop, GHCi doesn't seem to use any CPU time at all.
It's called a black hole. The runtime can detect that f directly depends on f, so just gives up early. Essentially it marks f as "black hole" once it starts evaluating it, and then when it comes back to f, it knows its already doing evaluation on f, so just fails. It would be useful if there was a page on the wiki about black holes, but I can't find one...
Many thanks for the explanation. But, if it can detect that is in a black hole, why doesn't it stop the computation altogether and return an error to the user? Best, titto
Thanks
Neil