On Tue, Mar 15, 2005 at 12:46:49AM +0800, Autrijus Tang wrote: : On Mon, Mar 14, 2005 at 05:28:29PM +0100, Miroslav Silovic wrote: : > But it gets worse. : > : > my $lines = [ =$fh ]; : > seek($fh, 0); : > my $lines2 = [ =$fh ]; : > close $fh; : > : > $lines2 must somehow remember that seek has happened. : : That is fine because the three thunks are registered to the fh : in evaluation order. What will be more fun is if they are all : part of some other lazy lists, which may be accessed in some : unpredictable order.
You could treat seek as a synchronization point like close. : : That is why lazy languages typically use some sort of typechecking to : avoid mixing computations with actions... :) Which is also what we're doing, except that we're hiding that fact from the user whenever we can rather than rubbing their nose in it. :-) Larry