[Haskell-beginners] what space leak could happen here?

Phil Xiaojun Hu phil at cnphil.com
Mon Sep 22 04:10:45 UTC 2014


On Sun, Sep 21, 2014 at 02:12:04PM -0600, Dimitri DeFigueiredo wrote:
> Thanks!
> 
> I don't quite understand the last sentence, though. So, it is a leak just
> because it needs to evaluate an element that may not be required? I thought
> a space leak implied we would be changing the "Big O" asymptotic order of
> space usage. How would the extra evaluation would change that?

Think of a network socket as the source of your list, and the first
character is all you need. If you need to evaluate the second character
to get the first, you could be stuck on the network socket for some
time waiting for the second one to come.

And I think the reason it would break some "Big O"s is that most
complexity analysis in Haskell are amortized bounds and it uses the fact
that Haskell is lazy and won't evaluate something until we actually need
it.

--
Phil Xiaojun Hu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140922/00bc6e38/attachment-0001.sig>


More information about the Beginners mailing list