sum, perfomance?

John van Groningen johnvg@cs.kun.nl
Tue, 6 Jun 2000 12:46:06 +0200


Adrian Hey wrote:
>...
>I would guess 1 reason for doing it this way is that this form is an easily
>optimised tail call, so resulting code resembles an imperative loop rather
>than recursive procedure calls. But this will only be efficient if strictness
>analyser detects that accsum is strict in its first argument (otherwise loads
>of thunks will be produced).

The strictness analyser does detect that accsum is strict.

>Actually, now I come to think about this, maybe the overloaded form of this
>means that strictness can't be inferred, it depends on the definition of
>the + instance??? No doubt a Clean developer can correct/clarify.

The strictness can be inferred because the instance of + for Int is strict and the compiler generates a specialised version of sum for [Int] because of the following export statements in StdList.dcl:

export + Int
export zero Int

>> P.S. How to subscribe to _both_ clean-announce and clean-list mailing
>> lists?
>
>I thought all announcements went to clean-list also, so you don't need
>to subscribe to both.

Yes, that is correct.

Regards,

John van Groningen