<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 2, 2014 at 1:20 AM, stepharo <span dir="ltr"><<a href="mailto:stepharo@free.fr" target="_blank">stepharo@free.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
What is the old behavior?<br></div></blockquote><div><br></div><div>These are from Smalltalk-80 v2 of</div><div><br></div><div>Object methods for private</div><div>species</div><div><span class="" style="white-space:pre">        </span>"Answer the preferred class for reconstructing the receiver. For example, </div><div><span class="" style="white-space:pre">        </span>collections create new collections whenever enumeration messages such as </div><div><span class="" style="white-space:pre">        </span>collect: or select: are invoked. The new kind of collection is determined by </div><div><span class="" style="white-space:pre">        </span>the species of the original collection. Species and class are not always the </div><div><span class="" style="white-space:pre">        </span>same. For example, the species of Interval is Array."</div><div><br></div><div><span class="" style="white-space:pre">        </span>^self class</div><div><br></div><div>Collection methods for enumerating</div><div><div>collect: aBlock </div><div><span class="" style="white-space:pre">        </span>"Evaluate aBlock with each of the receiver's elements as the argument. Collect the </div><div><span class="" style="white-space:pre">        </span>resulting values into a collection that is like the receiver. Answer the new </div><div><span class="" style="white-space:pre">        </span>collection. "</div><div><br></div><div><span class="" style="white-space:pre">        </span>| newCollection |</div><div><span class="" style="white-space:pre">        </span>newCollection _ self species new.</div><div><span class="" style="white-space:pre">        </span>self do: [:each | newCollection add: (aBlock value: each)].</div><div><span class="" style="white-space:pre">        </span>^newCollection</div></div><div><br></div><div><div>select: aBlock </div><div><span class="" style="white-space:pre">        </span>"Evaluate aBlock with each of the receiver's elements as the argument. </div><div><span class="" style="white-space:pre">        </span>Collect into a new collection like the receiver, only those elements for which</div><div><span class="" style="white-space:pre">        </span>aBlock evaluates to true. Answer the new collection."</div><div><br></div><div><span class="" style="white-space:pre">        </span>| newCollection |</div><div><span class="" style="white-space:pre">        </span>newCollection _ self species new.</div><div><span class="" style="white-space:pre">        </span>self do: [:each | (aBlock value: each) ifTrue: [newCollection add: each]].</div><div><span class="" style="white-space:pre">        </span>^newCollection</div></div><div><br></div><div>Interval methods for private</div><div><div>species</div><div><span class="" style="white-space:pre">        </span>^Array</div></div><div><br></div><div>But there are also already uses for comparing:</div><div><br></div><div>CharacterBlock methods for comparing</div><div><div>= aCharacterBlock </div><div><span class="" style="white-space:pre">        </span>self species = aCharacterBlock species</div><div><span class="" style="white-space:pre">                </span>ifTrue: [^stringIndex = aCharacterBlock stringIndex]</div><div><span class="" style="white-space:pre">                </span>ifFalse: [^false]</div></div><div><br></div><div>Interval methods for comparing</div><div><div>= anInterval </div><div><span class="" style="white-space:pre">        </span>"Answer true if my species and anInterval species are equal, and</div><div><span class="" style="white-space:pre">        </span>if our starts, steps and sizes are equal."</div><div><br></div><div><span class="" style="white-space:pre">        </span>self species == anInterval species</div><div><span class="" style="white-space:pre">                </span>ifTrue: [^start = anInterval first</div><div><span class="" style="white-space:pre">                                        </span>and: [step = anInterval increment and: [self size = anInterval size]]]</div><div><span class="" style="white-space:pre">                </span>ifFalse: [^false]</div></div><div><br></div><div><br></div><div>However, the species comment clearly states the usage pattern, even though it fails to mention the intent (to provide a mutable container with which to derive a new collection from the original).</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
In addition it would be good to have tests for such core library.<br></div></blockquote><div><br></div><div>+1</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
<br>
Stef<br>
<br>
<div>Le 1/12/14 11:44, Sven Van Caekenberghe
a écrit :<br>
</div><div><div class="h5">
<blockquote type="cite">
<br>
<div><br>
<blockquote type="cite">
<div>Begin forwarded message:</div>
<br>
<div style="margin:0px"><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif;color:rgb(0,0,0)"><b>From: </b></span><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif">Bert Freudenberg <<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>><br>
</span></div>
<div style="margin:0px"><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif;color:rgb(0,0,0)"><b>Subject: </b></span><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif"><b>Re: [squeak-dev]
IdentitySet>>collect:</b><br>
</span></div>
<div style="margin:0px"><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif;color:rgb(0,0,0)"><b>Date: </b></span><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif">1 Dec 2014 11:35:00 CET<br>
</span></div>
<div style="margin:0px"><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif;color:rgb(0,0,0)"><b>To: </b></span><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif">The general-purpose Squeak
developers list <<a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">squeak-dev@lists.squeakfoundation.org</a>><br>
</span></div>
<div style="margin:0px"><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif;color:rgb(0,0,0)"><b>Reply-To: </b></span><span style="font-family:-webkit-system-font,'Helvetica Neue',Helvetica,sans-serif">The general-purpose Squeak
developers list <<a href="mailto:squeak-dev@lists.squeakfoundation.org" target="_blank">squeak-dev@lists.squeakfoundation.org</a>><br>
</span></div>
<br>
<div>
<div style="word-wrap:break-word">On
01.12.2014, at 07:35, Colin Putney <<a href="mailto:colin@wiresong.com" target="_blank">colin@wiresong.com</a>> wrote:<br>
<div>
<blockquote type="cite"><br>
<div>
<div dir="ltr">On Sun, Nov 30, 2014 at 6:20
AM, Bert Freudenberg <span dir="ltr"><<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>></span>
wrote:<br>
<div class="gmail_extra">
<div class="gmail_quote">
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<div style="word-wrap:break-word">
<div><span></span>
<div>How would you define
“type” here? Same class?</div>
</div>
</div>
</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">Yes, same class. It might
be reasonable to answer instances of analogous
classes for weak collections, and expect the
caller to use #collect:as: if they want to
retain weakness. </div>
<div class="gmail_extra"><br>
</div>
<div class="gmail_extra">Colin</div>
</div>
</div>
</blockquote>
</div>
<div><br>
</div>
<div>That’s certainly simple:</div>
<div><br>
</div>
<div> “collect: returns a collection of the same
class as the receiver, except for weak collections,
which answer non-weak equivalents. To return a
collection of a different class, use collect:as:"</div>
<br>
<div>
<span>
<div style="word-wrap:break-word">
<div style="font-family:Helvetica"><span style="font-family:Helvetica">- Bert -</span></div>
</div>
</span></div>
</div>
</div>
</blockquote>
<br>
</div>
<div>The above definition makes perfect sense to me. The default
should be simple and predictable, the more complex and special
cases can be handled by a more convoluted API.</div>
<div><br>
</div>
<div>And we should change callers that depend on the old
behaviour.</div>
<div><br>
</div>
<div>Sven</div>
<div><br>
</div>
<br>
<br>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>