<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 4, 2015 at 9:07 AM, Chris Muller <span dir="ltr">&lt;<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>&gt;</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">isSequenceable is a term that refers to a particular *kind* of<br>
Collection, a sequenceable one.<br>
<br>
Therefore, IMO, I am unable to think of any more clear and explicit<br>
way of expressing that than &quot;isKindOf: SequenceableCollection&quot;...<br></blockquote><div><br></div><div>self isCollection and: [self isSequenceable]  is better.  isKinfOf: is a) not object-oriented as it forces an argument to be in a particular hierarchy rather than having a particular interface, and b) is horribly inefficient, causing a potentially long search of an object&#39;s class hierarchy.  isKindOf: doesn&#39;t just smell, it stinks.</div><div><br></div><div>So what do you prefer Chris, making isSequenceable an Object method too, or using self isCollection and: [self isSequenceable]?  I like the former because its simple, but you might have valid objections to extending Object.  That&#39;s why I&#39;m canvassing opinions.  I wont stop nuking isKindOf:&#39;s as I see them though ;-)</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 class=""><div class="h5"><br>
<br>
On Tue, Feb 3, 2015 at 8:59 PM, Eliot Miranda &lt;<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; On Tue, Feb 3, 2015 at 12:22 PM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; On Tue, 3 Feb 2015, <a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a> wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; Eliot Miranda uploaded a new version of Collections to project The Trunk:<br>
&gt;&gt;&gt; <a href="http://source.squeak.org/trunk/Collections-eem.603.mcz" target="_blank">http://source.squeak.org/trunk/Collections-eem.603.mcz</a><br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ==================== Summary ====================<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Name: Collections-eem.603<br>
&gt;&gt;&gt; Author: eem<br>
&gt;&gt;&gt; Time: 3 February 2015, 12:06:59.618 pm<br>
&gt;&gt;&gt; UUID: 6521c82f-d8de-4c07-a754-3bc3a8667746<br>
&gt;&gt;&gt; Ancestors: Collections-mt.602<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Three fewer uses of isKindOf:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; =============== Diff against Collections-mt.602 ===============<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Item was changed:<br>
&gt;&gt;&gt;  ----- Method: Dictionary&gt;&gt;= (in category &#39;comparing&#39;) -----<br>
&gt;&gt;&gt;  = aDictionary<br>
&gt;&gt;&gt;         &quot;Two dictionaries are equal if<br>
&gt;&gt;&gt;          (a) they are the same &#39;kind&#39; of thing.<br>
&gt;&gt;&gt;          (b) they have the same set of keys.<br>
&gt;&gt;&gt;          (c) for each (common) key, they have the same value&quot;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         self == aDictionary ifTrue: [ ^ true ].<br>
&gt;&gt;&gt; +       aDictionary isDictionary ifFalse: [^false].<br>
&gt;&gt;&gt; -       (aDictionary isKindOf: Dictionary) ifFalse: [^false].<br>
&gt;&gt;&gt;         self size = aDictionary size ifFalse: [^false].<br>
&gt;&gt;&gt;         self associationsDo: [:assoc|<br>
&gt;&gt;&gt;                 (aDictionary at: assoc key ifAbsent: [^false]) = assoc<br>
&gt;&gt;&gt; value<br>
&gt;&gt;&gt;                         ifFalse: [^false]].<br>
&gt;&gt;&gt;         ^true<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;  !<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Item was changed:<br>
&gt;&gt;&gt;  ----- Method: SequenceableCollection&gt;&gt;hasEqualElements: (in category<br>
&gt;&gt;&gt; &#39;comparing&#39;) -----<br>
&gt;&gt;&gt;  hasEqualElements: otherCollection<br>
&gt;&gt;&gt;         &quot;Answer whether the receiver&#39;s size is the same as<br>
&gt;&gt;&gt; otherCollection&#39;s<br>
&gt;&gt;&gt;         size, and each of the receiver&#39;s elements equal the corresponding<br>
&gt;&gt;&gt;         element of otherCollection.<br>
&gt;&gt;&gt;         This should probably replace the current definition of #= .&quot;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;         | size |<br>
&gt;&gt;&gt; +       otherCollection isSequenceable ifFalse: [^ false].<br>
&gt;&gt;&gt; -       (otherCollection isKindOf: SequenceableCollection) ifFalse: [^<br>
&gt;&gt;&gt; false].<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; This should either include an #isCollection check, or #isSequenceable<br>
&gt;&gt; should be moved up to Object.<br>
&gt;<br>
&gt;<br>
&gt; Oops.  Good catch.  Which would you do?  I favour the latter.<br>
&gt;<br>
&gt;&gt; Levente<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;&gt;         (size := self size) = otherCollection size ifFalse: [^ false].<br>
&gt;&gt;&gt;         1 to: size do:<br>
&gt;&gt;&gt;                 [:index |<br>
&gt;&gt;&gt;                 (self at: index) = (otherCollection at: index) ifFalse:<br>
&gt;&gt;&gt; [^ false]].<br>
&gt;&gt;&gt;         ^ true!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Item was changed:<br>
&gt;&gt;&gt;  ----- Method: String&gt;&gt;subStrings: (in category &#39;converting&#39;) -----<br>
&gt;&gt;&gt;  subStrings: separators<br>
&gt;&gt;&gt;         &quot;Answer an array containing the substrings in the receiver<br>
&gt;&gt;&gt; separated<br>
&gt;&gt;&gt;         by the elements of separators.&quot;<br>
&gt;&gt;&gt;         | char result sourceStream subString |<br>
&gt;&gt;&gt;         #Collectn.<br>
&gt;&gt;&gt;         &quot;Changed 2000/04/08 For ANSI &lt;readableString&gt; protocol.&quot;<br>
&gt;&gt;&gt; +       (separators isString or:[separators allSatisfy: [:element |<br>
&gt;&gt;&gt; element isCharacter]]) ifFalse:<br>
&gt;&gt;&gt; +               [^ self error: &#39;separators must be Characters.&#39;].<br>
&gt;&gt;&gt; -       (separators isString or:[separators allSatisfy: [:element |<br>
&gt;&gt;&gt; element isKindOf: Character]])<br>
&gt;&gt;&gt; -               ifFalse: [^ self error: &#39;separators must be<br>
&gt;&gt;&gt; Characters.&#39;].<br>
&gt;&gt;&gt;         sourceStream := ReadStream on: self.<br>
&gt;&gt;&gt;         result := OrderedCollection new.<br>
&gt;&gt;&gt;         subString := String new.<br>
&gt;&gt;&gt;         [sourceStream atEnd]<br>
&gt;&gt;&gt;                 whileFalse:<br>
&gt;&gt;&gt;                         [char := sourceStream next.<br>
&gt;&gt;&gt;                         (separators includes: char)<br>
&gt;&gt;&gt;                                 ifTrue: [subString notEmpty<br>
&gt;&gt;&gt;                                                 ifTrue:<br>
&gt;&gt;&gt;                                                         [result add:<br>
&gt;&gt;&gt; subString copy.<br>
&gt;&gt;&gt;                                                         subString :=<br>
&gt;&gt;&gt; String new]]<br>
&gt;&gt;&gt;                                 ifFalse: [subString := subString ,<br>
&gt;&gt;&gt; (String with: char)]].<br>
&gt;&gt;&gt;         subString notEmpty ifTrue: [result add: subString copy].<br>
&gt;&gt;&gt;         ^ result asArray!<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; best,<br>
&gt; Eliot<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">best,<div>Eliot</div></div>
</div></div>