Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Functional > Re: lazyness
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 53 Topic 2718 of 3057
Post > Topic >>

Re: lazyness

by Vesa Karvonen <vesa.karvonen@[EMAIL PROTECTED] > Jan 14, 2008 at 01:31 AM

Ben Franksen <ben.franksen@[EMAIL PROTECTED]
> wrote:
> Jon wrote:
[...]
> > Prelude> Data.List.foldl (+) 0 [1..1000000]
> > *** Exception: stack overflow
> > 
> > The first (strict) implementation works but the latter lazy
implementation
> > stack overflows in GHC. Will it stack overflow in the next Haskell
> > implementation (if there were one)? Who knows. Apparently it doesn't
stack
> > overflow in Hugs. [...]

> [...] Nothing here is unpredictable, it's mostly a matter of
> non-strict semantics.

I disagree.  What is unpredictable here is whether or not an unspecified
Haskell implementation is smart enough to evaluate the fold strictly.  It
is unpredictable, because it falls outside the Haskell definition (AFAIK).
An implementation may or may not evaluate the above fold strictly; strict
evaluation would be legal in this case.

Now, in this case, the programmer should, of course, use a strict fold.
The problem is that algorithms that ac***ulate a bounded size result given
a possibly very long input are very common.  This means that it is very
easy to accidentally introduce space leaks in a lazy language.  On a smart
implementation or small inputs, a particular program may work just fine.
On a naive implementation or larger inputs, the same program might leak
space like a pig.  Furthermore, a change to the program --- possibly even
far far away from a place where strict evaluation should have been used
--- may trigger a space leak, because space usage in a lazy language
depends on the run-time behavior of both producers and consumers or the
change might just happen to foil the strictness analyzer.

-Vesa Karvonen
 




 53 Posts in Topic:
lazyness
greg <mail@[EMAIL PROT  2008-01-07 04:57:43 
Re: lazyness
Ingo Menger <quetzalco  2008-01-07 05:04:56 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-11 00:25:48 
Re: lazyness
Vesa Karvonen <vesa.ka  2008-01-07 13:49:41 
Re: lazyness
Philippa Cowderoy <fli  2008-01-11 00:59:09 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-13 00:16:00 
Re: lazyness
Ben Franksen <ben.fran  2008-01-14 01:49:27 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-14 01:05:51 
Re: lazyness
Ben Franksen <ben.fran  2008-01-14 03:21:48 
Re: lazyness
Vesa Karvonen <vesa.ka  2008-01-14 01:31:39 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-14 15:32:55 
Re: lazyness
Ingo Menger <quetzalco  2008-01-11 06:12:24 
Re: lazyness
rossberg@[EMAIL PROTECTED  2008-01-11 07:10:05 
Re: lazyness
Philippa Cowderoy <fli  2008-01-11 20:31:12 
Re: lazyness
Vesa Karvonen <vesa.ka  2008-01-11 23:16:50 
Re: lazyness
Philippa Cowderoy <fli  2008-01-12 02:47:11 
Re: lazyness
Vesa Karvonen <vesa.ka  2008-01-12 11:11:17 
Re: lazyness
Vesa Karvonen <vesa.ka  2008-01-14 16:40:40 
Re: lazyness
Ingo Menger <quetzalco  2008-01-12 06:37:59 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-12 23:48:49 
Re: lazyness
Philippa Cowderoy <fli  2008-01-14 03:47:43 
Re: lazyness
Joachim Durchholz <jo@  2008-01-14 12:37:10 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-14 15:29:02 
Re: lazyness
Paul Rubin <http://phr  2008-01-14 08:10:06 
Re: lazyness
Joachim Durchholz <jo@  2008-01-15 15:42:52 
Re: lazyness
Adrian Hey <ahey@[EMAI  2008-01-15 19:18:04 
Re: lazyness
Paul Rubin <http://phr  2008-01-15 11:36:21 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-15 19:30:31 
Re: lazyness
Florian Kreidler <me@[  2008-01-15 16:40:28 
Re: lazyness
Florian Weimer <fw@[EM  2008-01-14 09:10:54 
Re: lazyness
Florian Weimer <fw@[EM  2008-01-15 00:05:26 
Re: lazyness
Vesa Karvonen <vesa.ka  2008-01-14 23:58:07 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-15 05:09:25 
Re: lazyness
George Neuner <gneuner  2008-01-15 13:00:52 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-16 00:16:23 
Re: lazyness
George Neuner <gneuner  2008-01-15 21:16:16 
Re: lazyness
Jon Harrop <usenet@[EM  2008-01-16 02:49:27 
Re: lazyness
George Neuner <gneuner  2008-01-16 17:36:29 
Re: lazyness
Philippa Cowderoy <fli  2008-01-15 19:14:10 
Re: lazyness
Florian Weimer <fw@[EM  2008-01-15 23:09:56 
Re: lazyness
Joachim Durchholz <jo@  2008-01-16 00:04:57 
Re: lazyness
Paul Rubin <http://phr  2008-01-15 15:22:50 
Re: lazyness
Joachim Durchholz <jo@  2008-01-16 11:40:21 
Re: lazyness
Philippa Cowderoy <fli  2008-01-18 03:38:19 
Re: lazyness
Joachim Durchholz <jo@  2008-01-18 17:11:13 
Re: lazyness
Paul Rubin <http://phr  2008-01-18 09:01:21 
Re: lazyness
Joachim Durchholz <jo@  2008-01-18 20:23:47 
Re: lazyness
Joachim Durchholz <jo@  2008-01-19 22:23:52 
Re: lazyness
Ben Bacarisse <ben.use  2008-01-19 13:02:32 
Re: lazyness
Philippa Cowderoy <fli  2008-01-19 16:43:00 
Re: lazyness
Philippa Cowderoy <fli  2008-01-19 21:50:48 
Re: lazyness
Joachim Durchholz <jo@  2008-01-19 23:10:39 
Re: lazyness
Philippa Cowderoy <fli  2008-01-19 23:01:26 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 7:43:05 CST 2008.