<div dir="ltr">what about<div>&nbsp;&nbsp; &nbsp; Collection class collect: aBlock from: aCollection</div><div>e.g.</div><div>&nbsp;&nbsp; &nbsp; Array collect:&nbsp;[:each | each codePoint] from: &#39;abc&#39;</div><div>?<br><br><div class="gmail_quote">On Sun, Sep 21, 2008 at 11:13 PM, Richard A. O&#39;Keefe <span dir="ltr">&lt;<a href="mailto:ok@cs.otago.ac.nz">ok@cs.otago.ac.nz</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Pretty much every Smalltalk I&#39;ve tried has failed this test:<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;&#39;abc&#39; collect: [:each | each codePoint]<br>
<br>
(or the equivalent using some non-standard replacement for<br>
#codePoint). &nbsp;It seems obvious to me that this should make<br>
a &quot;best effort&quot; attempt to collect the results of the block,<br>
just as<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;(97 to: 99) collect: [:each | Character codePoint: each]<br>
<br>
doesn&#39;t complain that an Interval can&#39;t store characters.<br>
I have on occasion reported this as a bug and provided code to<br>
make it work more or less as expected.<br>
<br>
My own library has in each collection class a class method<br>
 &nbsp; &nbsp; &nbsp; &nbsp;SomeCollection withAll: aCollection collect: aBlock<br>
so that I could hack this particular example using<br>
 &nbsp; &nbsp; &nbsp; &nbsp;Array withAll: &#39;abc&#39; collect: [:each | each codePoint]<br>
or even<br>
 &nbsp; &nbsp; &nbsp; &nbsp;ByteArray withAll: &#39;abc&#39;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;collect: [:each | each codePoint].<br>
<br>
Would adding #withAll:collect: to every class that has #withAll:<br>
be considered a good move?<br>
<br>
What exactly should #collect: do when sent to an object that<br>
belongs to a class whose instances cannot hold the results that<br>
the block returns?<br>
<br>
By the way, this particular example was not one constructed to<br>
break things; it&#39;s a simplified version of something that came up<br>
in real code.<br>
<br>
<br>
_______________________________________________<br>
ANSI-Smalltalk mailing list<br>
<a href="mailto:ANSI-Smalltalk@lists.openskills.org" target="_blank">ANSI-Smalltalk@lists.openskills.org</a><br>
<a href="http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk" target="_blank">http://lists.openskills.org/cgi-bin/mailman/listinfo/ansi-smalltalk</a><br>
</blockquote></div><br></div></div>