News for hackers. Stuff that matters.
Re:Do I really want to be using a language where memoize is ... by klodolph on Wednesday July 21, 2010 @07:58AM (#1534945)
I think you don't understand the Haskell runtime.

    let x = [1..]
    in do print (x !! 1000000)
          print (x !! 1000000)
Element #1000000 (counting from zero) of the list "x" is printed out twice. The first time, "x" is a thunk. That thunk is evaluated, and the runtime stores the resulting value back into "x". The second time, "x" is a constructor, so it does not need to be evaluated. You'll see the memory usage spike after the first "print" to account for the million cons cells allocated.

This is no different than the interface provided by the memoization function. What distinguishes pure from impure is not memory access -- memory MUST always be modified in order to perform calculation. I recommend reading the Haskell report section on semantics.

There are no comments on this comment yet.