[Haskell-cafe] Re: Web server continued
barsoap at web.de
Mon Dec 31 11:17:15 EST 2007
"Cristian Baboi" <cristi at ot.onrc.ro> wrote:
> What is more strange is that a = a + 1 and a = 1 + a are somehow
> distinct. The second give a stack overflow almost instanly, but the
> first don't.
That's because what the runtime does looks in the second case like
a = 1 + 1 + 1 + 1 + 1 + ... + a ...
and the first like
a = a = a = a = a = a = a = ... = 1 + a
, which is a much more space efficient endless loop.
That's not specified though, the runtime could choose to let + force
the two chunks the different way round.
(c) this sig last receiving data processing entity. Inspect headers for
past copyright information. All rights reserved. Unauthorised copying,
hiring, renting, public performance and/or broadcasting of this
More information about the Haskell-Cafe