hugs #of reductions
Alastair David Reid
reid@cs.utah.edu
09 Jul 2001 14:04:04 -0600
> Hi! We observed that often the evaluation of the same expression
> again requires fewer reductions than before.
Yes, you're seeing lazy evaluation in action.
The number of reductions isn't 0 the next time because you can't share
the result of the IO actions (e.g., putChar) used to display the
result.
This is an explicit design goal. It is useful when teaching lazy
evaluation to people. It may be possible to add a flag to Hugs so
that Hugs would clear all the CAFs (shared objects) at the end/start
of each evaluation. We talked about this a number of times but no-one
ever did it in Classic Hugs (I may have had it in STG-Hugs - can't
remember).
> It seems that the number of reductions hugs reports (:set +s) does
> not only depend on the program loaded and the expression evaluated
> but also on other things. What are they?
Just previous evaluations I think (and compiler version...)
> Is there a way to produce deterministic results; e.g., does a
> freshly loaded hugs on the same machine with the same program and
> evaluated expression always deliver the same number of reductions?
For a given version of the compiler/libraries, it should do.
It's probably a bug of some sort if it doesn't.
--
Alastair Reid reid@cs.utah.edu http://www.cs.utah.edu/~reid/