Lazy evaluation alternative
Chris Clearwater
chris@sharkzone.com
Fri, 24 Jan 2003 06:32:02 -0600
I wonder if I could run an idea I've had by this list. It seems to
me you could get some of the desired effects of lazy evaluation by using
continuation passing style in code. For example, take this psuedo-code
using CPS to represent an infinite data type.
Using non-CPS this would be something like:
ones = 1 : ones
using strict evaluation this would lead to an infinite loop.
However using CPS this could be represented as:
ones c = c (1 : ones)
where c is the continuation.
This would not infinite loop as ones is still waiting for the
continuation argument. Another example:
natural n c = c (n : natural n+1)
Again no infinite recursion!
What do you think? Please CC me in any reply.