<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:st1="urn:schemas-microsoft-com:office:smarttags" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags" name="PersonName"/>
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:595.3pt 841.9pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=DE link=blue vlink=blue>

<div class=Section1>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>hmm, the problem is
different IMO,<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>**corrected, but still
wrong**<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>(IdentitySet withAll: #(1
1.0)) collect: [:e| e asInteger ]&nbsp;&nbsp; IdentitySet(1 )<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal><font size=2 color=navy face=Arial><span lang=EN-GB
style='font-size:10.0pt;font-family:Arial;color:navy'>collect: should always
preserve the size of the original collection so it must return an
OrderedCollection !<o:p></o:p></span></font></p>

<div>

<div class=MsoNormal align=center style='text-align:center'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>

<hr size=2 width="100%" align=center tabindex=-1>

</span></font></div>

<p class=MsoNormal><b><font size=2 face=Tahoma><span style='font-size:10.0pt;
font-family:Tahoma;font-weight:bold'>Von:</span></font></b><font size=2
face=Tahoma><span style='font-size:10.0pt;font-family:Tahoma'>
squeak-dev-bounces@lists.squeakfoundation.org
[mailto:squeak-dev-bounces@lists.squeakfoundation.org] <b><span
style='font-weight:bold'>Im Auftrag von </span></b>Eliot Miranda<br>
<b><span style='font-weight:bold'>Gesendet:</span></b> Mittwoch, 26. November
2014 22:57<br>
<b><span style='font-weight:bold'>An:</span></b> <st1:PersonName w:st="on">The
 general-purpose Squeak developers list</st1:PersonName><br>
<b><span style='font-weight:bold'>Betreff:</span></b> Re: [squeak-dev]
IdentitySet&gt;&gt;collect:</span></font><o:p></o:p></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>On Wed, Nov 26, 2014 at 1:26 PM, Levente Uzonyi &lt;<a
href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt; wrote:<o:p></o:p></span></font></p>

<div>

<div>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>On Wed, 26 Nov 2014,
David T. Lewis wrote:<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>On Wed, Nov 26, 2014 at 08:01:49PM +0100, Levente Uzonyi wrote:<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>On Wed, 26 Nov 2014,
Eliot Miranda wrote:<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'>Hi All,<br>
? ? IdentitySet&gt;&gt;collect: answers a Set, not an IdentitySet.? Anyone else<br>
agree this is a serious bug?? Anyone else disagree?<br>
<br>
WTF??<br>
<br>
(IdentitySet withAll: #(1 2 3 1.0 2.0 3.0)) collect: [:e| e] a Set(1.0 2 3)<br>
--<br>
best,Eliot<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><br>
Sometimes it's feasable to return an IdentitySet, other times it's not, so<br>
there's no optimal solution - #collect: can't cover all cases.<br>
<br>
Set &gt;&gt; #collect: explicitly returns a Set, because this is the least bad<br>
solution to handle all of its subclasses reasonably well.<br>
In case of WeakSet, returning a WeakSet makes no sense, because some of<br>
your objects will disappear immediately.<br>
In case of IdentitySet, PluggableSet, KeyedSet and KeyedIdentitySet the<br>
returned values may not behave well in the original collection.<br>
<br>
The best is to always be explicit:<br>
<br>
(IdentitySet withAll: #(1 2 3 1.0 2.0 3.0)) collect: [ :e | e ] as:<br>
IdentitySet<br>
&quot;==&gt; an IdentitySet(1 2 3 1.0 2.0 3.0)&quot;<br>
<br>
Levente<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
In Squeak 2.8 (checked on <a
href="http://bertfreudenberg.github.io/SqueakJS/run/" target="_blank">http://bertfreudenberg.github.io/SqueakJS/run/</a>):<br>
<br>
&nbsp;(IdentitySet withAll: #(1 2 3 1.0 2.0 3.0)) collect: [:e| e] ==&gt; a
Set(2.0 1 2 3 3.0 1.0)<br>
<br>
<br>
But in trunk I get this:<br>
<br>
&nbsp;(IdentitySet withAll: #(1 2 3 1.0 2.0 3.0)) collect: [:e| e] ==&gt; a
Set(1 2 3)<br>
<br>
<br>
So answering a Set makes sense for the reasons that Levente explains, but trunk<br>
is definitely broken WRT the contents of that set.<br>
<br>
This bug needs a unit test to go along with whatever fix we agree on.<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>It's not a bug either. The Floats are not there, because they are equal
to the integers:<br>
<br>
1 = 1.0 &quot;==&gt; true&quot;<br>
1.0 = 1 &quot;==&gt; true&quot;<br>
<br>
Therefore they have the same hash:<br>
<br>
1 hash &quot;==&gt; 1&quot;<br>
1.0 hash &quot;==&gt; 1&quot;<br>
<br>
The bug was in Squeak 2.8:<br>
1.0 = 1 &quot;==&gt; true&quot;<br>
1 = 1.0 &quot;==&gt; true&quot;<br>
1 hash &quot;==&gt; 1&quot;<br>
1.0 hash &quot;==&gt; 61440&quot;<br>
<br>
Here's the comment of Float &gt;&gt; hash from The Trunk:<br>
&nbsp; &nbsp; &nbsp; &nbsp; &quot;Hash is reimplemented because = is
implemented. Both words of the float are used. (The bitShift:'s ensure that the
intermediate results do not become a large integer.) Care is taken to answer
same hash as an equal Integer.&quot;<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Exactly.<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>My hope would be something like this (Set order is arbitrary)<o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 color="#500050" face="Times New Roman"><span
style='font-size:12.0pt;color:#500050'>&nbsp; &nbsp; &nbsp; &nbsp;
((IdentitySet withAll: #(1 2 3 1.0 2.0 3.0)) collect: [:e| e]) =&gt;
IdentitySet (1 2 3 1.0 2.0 3.0)</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 color="#500050" face="Times New Roman"><span
style='font-size:12.0pt;color:#500050'>but that</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>&nbsp;<font color="#500050"><span style='color:#500050'>&nbsp; &nbsp;
&nbsp; (Set withAll: #(1 2 3 1.0 2.0 3.0)) =&gt; Set (1 2 3)</span></font><o:p></o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 color="#500050" face="Times New Roman"><span
style='font-size:12.0pt;color:#500050'>(and it always contains just the
integers since these are added first).</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<div>

<p class=MsoNormal><font size=3 color="#500050" face="Times New Roman"><span
style='font-size:12.0pt;color:#500050'>But Levente's collect:as: solution is
perfectly acceptable and as he points out has the advantage of being explicit.</span></font><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;
margin-left:4.8pt;margin-right:0cm'>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><br>
Levente<o:p></o:p></span></font></p>

<p class=MsoNormal style='margin-bottom:12.0pt'><font size=3
face="Times New Roman"><span style='font-size:12.0pt'><br>
Dave<br>
<br>
<br>
<o:p></o:p></span></font></p>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</blockquote>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><br>
<br clear=all>
<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>-- <o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>best,<o:p></o:p></span></font></p>

<div>

<p class=MsoNormal><font size=3 face="Times New Roman"><span style='font-size:
12.0pt'>Eliot<o:p></o:p></span></font></p>

</div>

</div>

</div>

</div>

</div>

</body>

</html>