The Trunk: Collections-edc.285.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

The Trunk: Collections-edc.285.mcz

commits-2
Edgar J. De Cleene uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-edc.285.mcz

==================== Summary ====================

Name: Collections-edc.285
Author: edc
Time: 29 January 2010, 7:01:04.567 am
UUID: b62a5e69-31ed-4958-b317-621a163b5a90
Ancestors: Collections-ul.284

-enh Add String > beginsWithAnyOf:

=============== Diff against Collections-ul.284 ===============

Item was added:
+ ----- Method: String>>beginsWithAnyOf: (in category 'comparing') -----
+ beginsWithAnyOf: aCollection
+ aCollection do:[:suffix|
+ (self beginsWith: suffix) ifTrue:[^true].
+ ].
+ ^false!


Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Igor Stasenko
On 29 January 2010 11:58,  <[hidden email]> wrote:

> Edgar J. De Cleene uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-edc.285.mcz
>
> ==================== Summary ====================
>
> Name: Collections-edc.285
> Author: edc
> Time: 29 January 2010, 7:01:04.567 am
> UUID: b62a5e69-31ed-4958-b317-621a163b5a90
> Ancestors: Collections-ul.284
>
> -enh Add String > beginsWithAnyOf:
>
> =============== Diff against Collections-ul.284 ===============
>
> Item was added:
> + ----- Method: String>>beginsWithAnyOf: (in category 'comparing') -----
> + beginsWithAnyOf: aCollection
> +       aCollection do:[:suffix|
> +               (self beginsWith: suffix) ifTrue:[^true].
> +       ].
> +       ^false!
>

Edgar,
things begin with _prefix_
but end with _suffix_
;)

Also, putting that into Collection protocol is wrong place, because
base Collection class does not
specifying any order over its elements. And therefore any terms like
'begins with..' or 'ends with..' is not applicable to it.
(for example Set can't implement this method reliably).

So, you should move that method down the hierarchy, which  is
SequenceableCollection..
Also, if you want to extend a protocol in such way, you should care
about symmetry,
since you adding new #beginsXXX method, it is logical to also have
symmetric #endsXXX with analoguous behavior.

>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Edgar J. De Cleene



On 1/29/10 8:44 AM, "Igor Stasenko" <[hidden email]> wrote:

> ends with..' is not applicable to it.
I have endsWithAnyOf: aCollection
    aCollection do:[:suffix|
        (self endsWith: suffix) ifTrue:[^true].
    ].
    ^false

It's of Yoshiki of 2004

So he is right and me wrong?

Edgar




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Edgar J. De Cleene
In reply to this post by Igor Stasenko



On 1/29/10 8:44 AM, "Igor Stasenko" <[hidden email]> wrote:

> Edgar,
> things begin with _prefix_
> but end with _suffix_


Ok I see

Must change suffix for prefix.
But still insist the method is useful, at least to me




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Edgar J. De Cleene
In reply to this post by Igor Stasenko



On 1/29/10 8:44 AM, "Igor Stasenko" <[hidden email]> wrote:

> Also, if you want to extend a protocol in such way, you should care
> about symmetry,
> since you adding new #beginsXXX method, it is logical to also have
> symmetric #endsXXX with analoguous behavior.


As said before, the image lack this simmetry and I correct it doing a
mistake :)

Edgar




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Igor Stasenko
In reply to this post by Igor Stasenko
On 29 January 2010 12:44, Igor Stasenko <[hidden email]> wrote:

> On 29 January 2010 11:58,  <[hidden email]> wrote:
>> Edgar J. De Cleene uploaded a new version of Collections to project The Trunk:
>> http://source.squeak.org/trunk/Collections-edc.285.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Collections-edc.285
>> Author: edc
>> Time: 29 January 2010, 7:01:04.567 am
>> UUID: b62a5e69-31ed-4958-b317-621a163b5a90
>> Ancestors: Collections-ul.284
>>
>> -enh Add String > beginsWithAnyOf:
>>
>> =============== Diff against Collections-ul.284 ===============
>>
>> Item was added:
>> + ----- Method: String>>beginsWithAnyOf: (in category 'comparing') -----
>> + beginsWithAnyOf: aCollection
>> +       aCollection do:[:suffix|
>> +               (self beginsWith: suffix) ifTrue:[^true].
>> +       ].
>> +       ^false!
>>
>
> Edgar,
> things begin with _prefix_
> but end with _suffix_
> ;)
>
> Also, putting that into Collection protocol is wrong place, because
> base Collection class does not
> specifying any order over its elements. And therefore any terms like
> 'begins with..' or 'ends with..' is not applicable to it.
> (for example Set can't implement this method reliably).
>
Oops sorry.. i mistakenly thought that you put it into Collection. But
it is in String.
Still, i think that SequenceableCollection is better place for it.

> So, you should move that method down the hierarchy, which  is
> SequenceableCollection..
> Also, if you want to extend a protocol in such way, you should care
> about symmetry,
> since you adding new #beginsXXX method, it is logical to also have
> symmetric #endsXXX with analoguous behavior.
>
>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko AKA sig.
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Edgar J. De Cleene



On 1/29/10 8:48 AM, "Igor Stasenko" <[hidden email]> wrote:

I send it again, this time with correct word and to inbox.
Sorry.

Igor could use this in another as String?
Like see...

Edgar




Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Igor Stasenko
On 29 January 2010 12:08, Edgar J. De Cleene <[hidden email]> wrote:

>
>
>
> On 1/29/10 8:48 AM, "Igor Stasenko" <[hidden email]> wrote:
>
> I send it again, this time with correct word and to inbox.
> Sorry.
>
> Igor could use this in another as String?
> Like see...
>
If you ask me, I hardly see a need in such methods at all.

> Edgar
>
>
>
>
>



--
Best regards,
Igor Stasenko AKA sig.

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

Levente Uzonyi-2
In reply to this post by commits-2
On Fri, 29 Jan 2010, [hidden email] wrote:

> Edgar J. De Cleene uploaded a new version of Collections to project The Trunk:
> http://source.squeak.org/trunk/Collections-edc.285.mcz
>
> ==================== Summary ====================
>
> Name: Collections-edc.285
> Author: edc
> Time: 29 January 2010, 7:01:04.567 am
> UUID: b62a5e69-31ed-4958-b317-621a163b5a90
> Ancestors: Collections-ul.284
>
> -enh Add String > beginsWithAnyOf:
>

What about removing this and #endsWithAnyOf: too?
#endsWithAnyOf: has only a single sender in the current image, and it
doesn't seems to be generally useful.

If we are about to keep them, then this implementation seems to be more
readable:

    ^aCollection anySatisfy: [ :each | self beginsWith: each ]


Levente

> =============== Diff against Collections-ul.284 ===============
>
> Item was added:
> + ----- Method: String>>beginsWithAnyOf: (in category 'comparing') -----
> + beginsWithAnyOf: aCollection
> + aCollection do:[:suffix|
> + (self beginsWith: suffix) ifTrue:[^true].
> + ].
> + ^false!
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: The Trunk: Collections-edc.285.mcz

keith1y
In reply to this post by Igor Stasenko
>>> + ----- Method: String>>beginsWithAnyOf: (in category 'comparing')  
>>> -----

Since this is not that hard to implement yourself, do you really need  
to add this to String?

listOfPrefixes anySatisfies: [ :ea | string beginsWith: ea ].

Keith