<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"><<a href="mailto:asqueaker@gmail.com" target="_blank">asqueaker@gmail.com</a>></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 "isKindOf: SequenceableCollection"...<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's class hierarchy. isKindOf: doesn'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's why I'm canvassing opinions. I wont stop nuking isKindOf:'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 <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
><br>
><br>
> On Tue, Feb 3, 2015 at 12:22 PM, Levente Uzonyi <<a href="mailto:leves@elte.hu">leves@elte.hu</a>> wrote:<br>
>><br>
>> On Tue, 3 Feb 2015, <a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a> wrote:<br>
>><br>
>>> Eliot Miranda uploaded a new version of Collections to project The Trunk:<br>
>>> <a href="http://source.squeak.org/trunk/Collections-eem.603.mcz" target="_blank">http://source.squeak.org/trunk/Collections-eem.603.mcz</a><br>
>>><br>
>>> ==================== Summary ====================<br>
>>><br>
>>> Name: Collections-eem.603<br>
>>> Author: eem<br>
>>> Time: 3 February 2015, 12:06:59.618 pm<br>
>>> UUID: 6521c82f-d8de-4c07-a754-3bc3a8667746<br>
>>> Ancestors: Collections-mt.602<br>
>>><br>
>>> Three fewer uses of isKindOf:<br>
>>><br>
>>> =============== Diff against Collections-mt.602 ===============<br>
>>><br>
>>> Item was changed:<br>
>>> ----- Method: Dictionary>>= (in category 'comparing') -----<br>
>>> = aDictionary<br>
>>> "Two dictionaries are equal if<br>
>>> (a) they are the same 'kind' of thing.<br>
>>> (b) they have the same set of keys.<br>
>>> (c) for each (common) key, they have the same value"<br>
>>><br>
>>> self == aDictionary ifTrue: [ ^ true ].<br>
>>> + aDictionary isDictionary ifFalse: [^false].<br>
>>> - (aDictionary isKindOf: Dictionary) ifFalse: [^false].<br>
>>> self size = aDictionary size ifFalse: [^false].<br>
>>> self associationsDo: [:assoc|<br>
>>> (aDictionary at: assoc key ifAbsent: [^false]) = assoc<br>
>>> value<br>
>>> ifFalse: [^false]].<br>
>>> ^true<br>
>>><br>
>>> !<br>
>>><br>
>>> Item was changed:<br>
>>> ----- Method: SequenceableCollection>>hasEqualElements: (in category<br>
>>> 'comparing') -----<br>
>>> hasEqualElements: otherCollection<br>
>>> "Answer whether the receiver's size is the same as<br>
>>> otherCollection's<br>
>>> size, and each of the receiver's elements equal the corresponding<br>
>>> element of otherCollection.<br>
>>> This should probably replace the current definition of #= ."<br>
>>><br>
>>> | size |<br>
>>> + otherCollection isSequenceable ifFalse: [^ false].<br>
>>> - (otherCollection isKindOf: SequenceableCollection) ifFalse: [^<br>
>>> false].<br>
>><br>
>><br>
>> This should either include an #isCollection check, or #isSequenceable<br>
>> should be moved up to Object.<br>
><br>
><br>
> Oops. Good catch. Which would you do? I favour the latter.<br>
><br>
>> Levente<br>
>><br>
>><br>
>>> (size := self size) = otherCollection size ifFalse: [^ false].<br>
>>> 1 to: size do:<br>
>>> [:index |<br>
>>> (self at: index) = (otherCollection at: index) ifFalse:<br>
>>> [^ false]].<br>
>>> ^ true!<br>
>>><br>
>>> Item was changed:<br>
>>> ----- Method: String>>subStrings: (in category 'converting') -----<br>
>>> subStrings: separators<br>
>>> "Answer an array containing the substrings in the receiver<br>
>>> separated<br>
>>> by the elements of separators."<br>
>>> | char result sourceStream subString |<br>
>>> #Collectn.<br>
>>> "Changed 2000/04/08 For ANSI <readableString> protocol."<br>
>>> + (separators isString or:[separators allSatisfy: [:element |<br>
>>> element isCharacter]]) ifFalse:<br>
>>> + [^ self error: 'separators must be Characters.'].<br>
>>> - (separators isString or:[separators allSatisfy: [:element |<br>
>>> element isKindOf: Character]])<br>
>>> - ifFalse: [^ self error: 'separators must be<br>
>>> Characters.'].<br>
>>> sourceStream := ReadStream on: self.<br>
>>> result := OrderedCollection new.<br>
>>> subString := String new.<br>
>>> [sourceStream atEnd]<br>
>>> whileFalse:<br>
>>> [char := sourceStream next.<br>
>>> (separators includes: char)<br>
>>> ifTrue: [subString notEmpty<br>
>>> ifTrue:<br>
>>> [result add:<br>
>>> subString copy.<br>
>>> subString :=<br>
>>> String new]]<br>
>>> ifFalse: [subString := subString ,<br>
>>> (String with: char)]].<br>
>>> subString notEmpty ifTrue: [result add: subString copy].<br>
>>> ^ result asArray!<br>
>>><br>
>>><br>
>>><br>
>><br>
><br>
><br>
><br>
> --<br>
> best,<br>
> Eliot<br>
><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>