On 29-Sep-1999, S.D.Mechveliani <[EMAIL PROTECTED]> wrote:
> As to Haskell, what might it do when, say, condition1 p = all (< 20) p
> starts to evaluate?
> It tries first to find head p < 20.
> This has to apply `<' to head p.
> p is needed for other part of the program. Probably, the interpreter
> sees that the node of p is referenced more than once at this moment.
> So, fearing that evaluation of head p < 20 may destroy the value of
> p, the interpreter copies head p before applying `<'.
No. Haskell implementations don't use destructive update
(except for things in the IO Monad or similar),
so evaluation of `heap p < 20' will definitely not destroy the
value of `p', and so there is no need for the Haskell implementation
to make a copy in that case.
> In this manner, it will copy all the list p before condition1 p
> is evaluated.
> What the Haskell implementors would say, does Haskell act this way?
No.
> Further, observing all these functions, the compiler might conclude
> that the result does not need at all forming permutations on new place.
> Could it code this into forming of permutations "in-place" ?
> The language does not allow to express this. But the compiler has such
> freedom. It might use it in the simple cases when it succeeds to detect
> the "in-place" possibility.
> - ?
That's possible, but current Haskell compilers don't do it.
The Clean implementation does perform this kind of in-place update
optimization in some cases.
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.