[squeak-dev] Re: Collection>>sum implementation

Jerome Peace peace_the_dreamer at yahoo.com
Tue Aug 12 04:08:39 UTC 2008


[squeak-dev] Re: Collection>>sum implementation
Klaus D. Witzel klaus.witzel at cobss.com 
Mon Aug 11 22:56:40 UTC 2008 

Hi Klaus, Hi Randal

Thanks for your replys to my post.

On Mon, 11 Aug 2008 22:47:25 +0200, Randal L. Schwartz wrote:

>>>>>> "Jerome" == Jerome Peace <peace_the_dreamer at yahoo.com> writes:
>
> Jerome> You let it tell you:
>
> Jerome> any := myCollection anyOne  .
> Jerome> zeroElement := any - any .

***
Klaus>Problem here is that #() has no anyOne, and so #negated (assuming that
Klaus>sum wants to do #+) can also not be used.

Currently summing over the empty list signals an error.
That seems right.

If something needs the behavior otherwise it could wrap a call to sum with a check for special conditions 
such as isEmpty or isNil. Then just return the special answer with a guard clause.

***
RandaL wrote:
> This presumes that anything that implements #+ is also expected
> to implement #-.  

Yes. #sum currently is spec'ed to assume that anyway.

In 3.10.2 only AbstractSound implements + without also implementing #-.

>Yes, that was also present in the original implementation,
> but a version that doesn't require that would be nice.

Why?
And why program it before it is needed?

And please look at the mantis report. It shows why the fix is needed.


Yours in service and curiosity, --Jerome Peace



      



More information about the Squeak-dev mailing list