<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 26, 2014 at 4:31 PM, David T. Lewis <span dir="ltr">&lt;<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It seems to me that Object&gt;&gt;species is intended to handle this sort of issue.<br></blockquote><div><br></div><div>You&#39;re right.  That&#39;s what it&#39;s there for.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">For IdentitySet, it answers what Eliot was expecting:<br>
<br>
   IdentitySet new species ==&gt; IdentitySet<br>
   Set new species ==&gt; Set<br>
<br>
However, IdentitySet&gt;&gt;collect: does not make use of this, and it answers<br>
a Set for the reasons that Levente explained.<br>
<br>
Answering an Array or and OrderedCollection would not really make sense,<br>
because sets are unordered collections (but Bag might be better).<br>
<br>
Shouldn&#39;t we have an implementation of IdentitySet&gt;&gt;species that answers<br>
Set (or Bag), with a method comment explaining why this is the case, and<br>
with all of the collection methods using #species to answer the right<br>
kind of result?<br>
<br>
I note that IdentitySet&gt;&gt;collect: answers a Set, but IdentitySet&gt;select:<br>
sends #species and therefore answers an IdentitySet.<br>
<br>
So I think that if we want the #species of an IdentitySet to be a Set,<br>
then we should make it so, and give it a method comment to explain the<br>
rationale. And the #collect: and #select: methods should both answer a<br>
result of that #species.<br></blockquote><div><br></div><div>+1</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dave<br>
<div><div class="h5"><br>
<br>
On Thu, Nov 27, 2014 at 01:14:30AM +0100, Levente Uzonyi wrote:<br>
&gt; Your example hides the problem of ordering - what Tobias is asking about -<br>
&gt; so here&#39;s another:<br>
&gt;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each class ]<br>
&gt;<br>
&gt; If IdentitySet &gt;&gt; #collect: were returning an Array, then what would be the<br>
&gt; answer?<br>
&gt;<br>
&gt; { SmallInteger. Float } or { Float. SmallInteger } ?<br>
&gt;<br>
&gt; If you really want to have the resulting collection have the same size,<br>
&gt; but avoid the problem with ordering, then what you really need is a Bag.<br>
&gt; Luckily you can have whatever you want (as long as it makes sense):<br>
&gt;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as: Set.<br>
&gt; &quot;==&gt; a Set(1)&quot;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
&gt; IdentitySet.<br>
&gt; &quot;==&gt; an IdentitySet(1)&quot;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
&gt; Array.<br>
&gt; &quot;==&gt; #(1 1)&quot;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
&gt; OrderedCollection.<br>
&gt; &quot;==&gt; an OrderedCollection(1 1).&quot;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as: Bag.<br>
&gt; &quot;==&gt; a Bag(1 1)&quot;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
&gt; IdentityBag.<br>
&gt; &quot;==&gt; an IdentityBag(1 1)&quot;<br>
&gt; (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
&gt; Heap.<br>
&gt; &quot;==&gt; a Heap(1 1)&quot;<br>
&gt;<br>
&gt; Levente<br>
&gt;<br>
&gt; On Thu, 27 Nov 2014, Frank Lesser wrote:<br>
&gt;<br>
&gt; &gt;Hi Tobias,<br>
&gt; &gt;agree, a problem of &quot;OrderedCollection&quot;<br>
&gt; &gt;not to break a lot of other things we could return an Array.<br>
&gt; &gt;but for me collecting has priority.<br>
&gt; &gt;Frank<br>
&gt; &gt;<br>
</div></div>&gt; &gt;-----Urspr?ngliche Nachricht-----<br>
<div class="HOEnZb"><div class="h5">&gt; &gt;Von: <a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org">squeak-dev-bounces@lists.squeakfoundation.org</a><br>
&gt; &gt;[mailto:<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org">squeak-dev-bounces@lists.squeakfoundation.org</a>] Im Auftrag von<br>
&gt; &gt;Tobias<br>
&gt; &gt;Pape<br>
&gt; &gt;Gesendet: Donnerstag, 27. November 2014 00:48<br>
&gt; &gt;An: The general-purpose Squeak developers list<br>
&gt; &gt;Betreff: Re: [squeak-dev] IdentitySet&gt;&gt;collect:<br>
&gt; &gt;<br>
&gt; &gt;<br>
&gt; &gt;On 27.11.2014, at 00:34, Frank Lesser &lt;<a href="mailto:frank-lesser@lesser-software.com">frank-lesser@lesser-software.com</a>&gt;<br>
&gt; &gt;wrote:<br>
&gt; &gt;<br>
&gt; &gt;&gt;hmm, not convinced<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;(IdentitySet withAll: #(1 1.0)) collect: [:e| e asInteger ]<br>
&gt; &gt;&gt;OrderedCollection(1 1 )<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;in LSWVST ( one-to-one ), you collect results of evaluating a block on<br>
&gt; &gt;&gt;objects.<br>
&gt; &gt;&gt;<br>
&gt; &gt;&gt;Frank<br>
&gt; &gt;&gt;maybe I am wrong ...<br>
&gt; &gt;<br>
&gt; &gt;Where would the order come from for that _Ordered_Collection?<br>
&gt; &gt;<br>
&gt; &gt;Best<br>
&gt; &gt;     -Tobias<br>
&gt; &gt;<br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>