At 08:45 -0700 1999/04/19, Mark P Jones wrote:
...
>Your observations are correct, and this was an intentional design feature of
>Gofer, which has carried over into Hugs.

In private communications with Pablo Azero <[EMAIL PROTECTED]>, we were able
to figure out some of this stuff.

>There is a simple way to release
>the
>storage for fib, which is to reload fib.hs (or any other file, or even
>nothing
>using :load with no arguments).

So this one I noticed.

>..note that, if you
>want to write a version of fib that doesn't hold on to the partially
>computed list beyond a single use of that list, then you should rewrite your
>definition as:
>
>  fib   :: () -> [Integer]
>  fib () = fibs where fibs = 1 : 1 : zipWith (+) fibs (tail fibs)
>
>And compare the behavior of this definition with the following, seemingly
>modest variation:
>
>  fib   :: () -> [Integer]
>  fib () = 1 : 1 : zipWith (+) (fib ()) (tail (fib ()))

>From what I could see, Hugs views the top level definitions, and its
partial computations, as a root set for the GC (garbage collector). My
guess is that has to do something with not having to do partial
computations over again, would they be needed.

>This has been a controversial point in the design, and some folks will tell
>you that I made the wrong choice.  I'm sure that I've written about my
>rationale for this behaviour in the Gofer user manual or implementation
>report, so I won't go into it again here.

So my guess is that one wants to partially collect a partial top level
computation, one needs figure out a good strategy for doing that.

  Hans Aberg
                  * Email: Hans Aberg <mailto:[EMAIL PROTECTED]>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>

Reply via email to