<div dir="ltr"><div dir="ltr"><div dir="ltr">Hi Tim,</div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 8, 2019 at 11:36 AM tim Rowledge <<a href="mailto:tim@rowledge.org">tim@rowledge.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">#() sum -> errorEmptyCollection.<br>
<br>
#sum uses #reduce: and I can see why #reduce might consider an empty collection an error - but I also see that #sum of an empty collection probably ought to be 0, at least in a lot of cases. And I'd note that using a simple #inject:into: - in the case of a million item Array, at least - took about 60% of the time of the current #sum.<br>
<br>
Why did this come up? In an MVC Project I tested <br>
  PluggableFileList getFolderDialog openLabel: 'foo'<br>
whilst seeing if PluggableFileList had any uses. It turns out that building a PluggableFileList in MVC doesn't work. Somewhere we end up trying to build a pluggablepanel with no children, which makes the logic in MVCToolBuilder>>setLayout:in: get upset. I don't care enough about making MVC stuff work to be willing to spend time on that.<br></blockquote><div><br></div><div>IIRC we discussed this issue carefully.  The issue was typing.  Clearly one should only be able to compute the sum of a collection of numbers (or things that answer to + and can be an argument to 0 + ...).  So we wanted to check that there was at least one numbers element in the receiver and hence chose that sum should indeed fail for an empty collection.  It still seems like a reasonable choice to me.  see e.g. <a href="http://forum.world.st/squeak-dev-Re-Collection-gt-gt-sum-implementation-td77002.html#a77008">http://forum.world.st/squeak-dev-Re-Collection-gt-gt-sum-implementation-td77002.html#a77008</a></div></div><div><br></div><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div>