$sum, dosum and simplifcation



On 2/20/10, Stavros Macrakis <macrakis at alum.mit.edu> wrote:

> The current behavior is *not* the 40-year-old behavior -- it is something
> that Dodier changed

Yes. I changed it to fix various bug reports. Also I changed it after a
lengthy correspondence with Barton W, and you as well on occasion.
Finally, I changed it after posting a message to the mailing list about it
(which drew no responses).

> (against your objections and mine if I remember correctly) a few years ago.

I went back through my email and the bug reports and I found
no evidence of this claim.

> Perhaps the clean but user-friendly thing to do is to define sum(a,b,c,d) as
> syntactic sugar for sum(lambda([b],a),integer_sequence(c,d)) and have the
> semantics follow from that.  But there are still the simplification problems
> mentioned above.

This is a good idea & worth considering, but at this point I think a
simpler remedy is just to make sum an ordinary defun, like integrate.
That will do away with the unusual evaluation mechanism, which
allows the summation index to be considered a local variable, but
that small benefit is outweighed by the grief brought on by
unusual evaluation. The problem is that it is hard to understand
what sum is going to do in some cases -- let's make it easy to
predict by just making it a defun.

FWIW

Robert Dodier