> > > collection. I want to try to force l to be generated on-the-fly
> > > every time it is needed, to see if it improves performance.
> > > What is a good way to do it? Would something like
> > >
> ...
> > The easiest way is to make it a function
> >
> > l _ = [ i*i*i | i <- [0..n] ]   -- for very large n
>
> 
> I asked a similar question a while ago, and (I think) there was general
> agreement that this was not a reliable solution because the expression

I found a solution which works in some cases. For example:

reeval f x = do xref <- newIORef x
                x' <- readIORef xref
                return (f x')

Then the IO action "reeval f x"
should reevalue f each time it is invoked. Is this safe? Will this work
in all cases?

Thanks for any comments.



-- 
-------------------------------------------------------------------------
Jan Kybic <[EMAIL PROTECTED]>      Odyssee, INRIA, Sophia-Antipolis, France
       or <[EMAIL PROTECTED]>,tel. work +33 492 38 7589, fax 7845
             http://www-sop.inria.fr/odyssee/team/Jan.Kybic/index.en.html
_______________________________________________
Haskell mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell

Reply via email to