Another question about sharing
Wed, 12 Dec 2001 07:47:44 +0000
On Monday 10 December 2001 3:32 pm, Simon Marlow wrote:
> The problem isn't restricted to CAFs - full laziness always trades space
> for time. We found that it can be a large win in some cases: if
> repeated computation is replaced by sharing in an inner loop, then the
> gains can be dramatic. We didn't meet any cases where it caused space
> problems, so you get it by default when optimisation is turned on in
> GHC. You can always disable it with -fno-full-laziness.
and Malcolm Wallace wrote:
> Well, how about the following little circular program?
> paths :: () -> [Path]
> paths () = let r = T : branch r in r
Just to be clear, (with GHC) if I compile a module with this
flag, with a local definition of paths..
mkLUT def = <blah> where
paths = T : branch paths
then I'll get a new paths graph every time mkLUT is called?
But the effect of this is local to the module, so if mkLUT
is exported, any local use of (mkLUT def) where def is a
constant will still give a CAF (containing paths) unless
that module has also been compiled with -fno-full-laziness?
If I'm not mistaken, I have essentially the same problem
with Malcolms solution. (() is a constant.)
I don't want to make too big an issue over this because
it really isn't a show stopper for my purposes, but it
would be nice if I could make (what I consider to be)
a reasonably safe self contained library module.
I.E. Doesn't contain or cause space leaks
Is not GHC specific
Doesn't require other modules which make use
of it to be compiled with particular options.
I wonder if those people who know more about formal semantics
than I do might consider making the definition of the language
less ambiguous wrt sharing and also (maybe) giving programmers
more explicit control if they need it, as in Clean.
BTW, I can't find any information re. -fno-full-laziness in the
current GHC users guide. Is it a deprecated feature?
If I try it in an OPTIONS pragma I discover that it's static.
Does that mean it has to be applied to a whole program in any
case? (I can't think of any other reason it can't be included
in a source file).