[racket] Space safety in lazy

From: Rodolfo Carvalho (rhcarvalho at gmail.com)
Date: Sun Feb 19 01:02:58 EST 2012

I was reading Matthew Flatt's slides [1] and tried out an example using
#lang lazy that IIUC should run "forever":

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang lazy

(define (list-from n)
  (cons n (list-from (add1 n))))

(define (has-negative? l)
  (or (negative? (car l))
      (has-negative? (rest l))))

(has-negative? (list-from 0))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


However, after a minute or so it gives an out of memory error.
DrRacket is set to use up to 256 MB, and even if I raise the limit to 512
MB, eventually I get:

"The evaluation thread is no longer running, so no evaluation can take
place until the next execution.
The program ran out of memory."

Is it expected to happen? Why?



Thanks,

Rodolfo Carvalho


[1] http://www.eng.utah.edu/~cs6510/space.pdf
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120219/5a75e308/attachment-0001.html>

Posted on the users mailing list.