<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"><<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>></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>>species is intended to handle this sort of issue.<br></blockquote><div><br></div><div>You're right. That's what it'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 ==> IdentitySet<br>
Set new species ==> Set<br>
<br>
However, IdentitySet>>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't we have an implementation of IdentitySet>>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>>collect: answers a Set, but IdentitySet>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>
> Your example hides the problem of ordering - what Tobias is asking about -<br>
> so here's another:<br>
><br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each class ]<br>
><br>
> If IdentitySet >> #collect: were returning an Array, then what would be the<br>
> answer?<br>
><br>
> { SmallInteger. Float } or { Float. SmallInteger } ?<br>
><br>
> If you really want to have the resulting collection have the same size,<br>
> but avoid the problem with ordering, then what you really need is a Bag.<br>
> Luckily you can have whatever you want (as long as it makes sense):<br>
><br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as: Set.<br>
> "==> a Set(1)"<br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
> IdentitySet.<br>
> "==> an IdentitySet(1)"<br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
> Array.<br>
> "==> #(1 1)"<br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
> OrderedCollection.<br>
> "==> an OrderedCollection(1 1)."<br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as: Bag.<br>
> "==> a Bag(1 1)"<br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
> IdentityBag.<br>
> "==> an IdentityBag(1 1)"<br>
> (IdentitySet withAll: #(1 1.0)) collect: [ :each | each asInteger ] as:<br>
> Heap.<br>
> "==> a Heap(1 1)"<br>
><br>
> Levente<br>
><br>
> On Thu, 27 Nov 2014, Frank Lesser wrote:<br>
><br>
> >Hi Tobias,<br>
> >agree, a problem of "OrderedCollection"<br>
> >not to break a lot of other things we could return an Array.<br>
> >but for me collecting has priority.<br>
> >Frank<br>
> ><br>
</div></div>> >-----Urspr?ngliche Nachricht-----<br>
<div class="HOEnZb"><div class="h5">> >Von: <a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org">squeak-dev-bounces@lists.squeakfoundation.org</a><br>
> >[mailto:<a href="mailto:squeak-dev-bounces@lists.squeakfoundation.org">squeak-dev-bounces@lists.squeakfoundation.org</a>] Im Auftrag von<br>
> >Tobias<br>
> >Pape<br>
> >Gesendet: Donnerstag, 27. November 2014 00:48<br>
> >An: The general-purpose Squeak developers list<br>
> >Betreff: Re: [squeak-dev] IdentitySet>>collect:<br>
> ><br>
> ><br>
> >On 27.11.2014, at 00:34, Frank Lesser <<a href="mailto:frank-lesser@lesser-software.com">frank-lesser@lesser-software.com</a>><br>
> >wrote:<br>
> ><br>
> >>hmm, not convinced<br>
> >><br>
> >>(IdentitySet withAll: #(1 1.0)) collect: [:e| e asInteger ]<br>
> >>OrderedCollection(1 1 )<br>
> >><br>
> >>in LSWVST ( one-to-one ), you collect results of evaluating a block on<br>
> >>objects.<br>
> >><br>
> >>Frank<br>
> >>maybe I am wrong ...<br>
> ><br>
> >Where would the order come from for that _Ordered_Collection?<br>
> ><br>
> >Best<br>
> > -Tobias<br>
> ><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>