String operations

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

String operations

Peter Uhnak
Hi,

am I really blind, or is there no way to do something like
'BormParticipant' removePrefix: 'Borm' "-> 'Participant'"
or
'BormParticipant' copyFrom: 5 "-> 'Participant'" "OrderedCollection knows this"

I can do copyFrom:to:, but that requires asking the size of the string, which is (in my eyes) ugly.

So is there better (=single message) way?

Thanks,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: String operations

HilaireFernandes
Hello Peter,

Finder can't find when you need to compose two messages, this one does it:

('BormParticipant' splitOn: 'Borm') last

Hilaire

Le 06/04/2015 12:34, Peter Uhnák a écrit :

> Hi,
>
> am I really blind, or is there no way to do something like
> 'BormParticipant' removePrefix: 'Borm' "-> 'Participant'"
> or
> 'BormParticipant' copyFrom: 5 "-> 'Participant'" "OrderedCollection
> knows this"
>
> I can do copyFrom:to:, but that requires asking the size of the
> string, which is (in my eyes) ugly.
>
> So is there better (=single message) way?
>
> Thanks,
> Peter


--
Dr. Geo - http://drgeo.eu
iStoa - http://istoa.drgeo.eu



Reply | Threaded
Open this post in threaded view
|

Re: String operations

NorbertHartl
In reply to this post by Peter Uhnak
If you have the amount auf characters you want to omit you can do

'BormParticipant' allButFirst: 4

Norbert

> Am 06.04.2015 um 12:34 schrieb Peter Uhnák <[hidden email]>:
>
> Hi,
>
> am I really blind, or is there no way to do something like
> 'BormParticipant' removePrefix: 'Borm' "-> 'Participant'"
> or
> 'BormParticipant' copyFrom: 5 "-> 'Participant'" "OrderedCollection knows this"
>
> I can do copyFrom:to:, but that requires asking the size of the string, which is (in my eyes) ugly.
>
> So is there better (=single message) way?
>
> Thanks,
> Peter


Reply | Threaded
Open this post in threaded view
|

Re: String operations

Tudor Girba-2
In the Moose configuration, there is a CollectionExtensions that allows you to do this:
'BormParticipant' removePrefix: 'Borm' "-> 'Participant'".
'BormParticipant' removeSuffix: 'Participant' "-> 'Borm'"

For Pharo 5, we should move these extensions to Pharo.

Cheers,
Doru


On Mon, Apr 6, 2015 at 12:51 PM, Norbert Hartl <[hidden email]> wrote:
If you have the amount auf characters you want to omit you can do

'BormParticipant' allButFirst: 4

Norbert

> Am 06.04.2015 um 12:34 schrieb Peter Uhnák <[hidden email]>:
>
> Hi,
>
> am I really blind, or is there no way to do something like
> 'BormParticipant' removePrefix: 'Borm' "-> 'Participant'"
> or
> 'BormParticipant' copyFrom: 5 "-> 'Participant'" "OrderedCollection knows this"
>
> I can do copyFrom:to:, but that requires asking the size of the string, which is (in my eyes) ugly.
>
> So is there better (=single message) way?
>
> Thanks,
> Peter





--

"Every thing has its own flow"
Reply | Threaded
Open this post in threaded view
|

Re: String operations

NorbertHartl

Am 06.04.2015 um 21:28 schrieb Tudor Girba <[hidden email]>:

In the Moose configuration, there is a CollectionExtensions that allows you to do this:
'BormParticipant' removePrefix: 'Borm' "-> 'Participant'".
'BormParticipant' removeSuffix: 'Participant' "-> 'Borm'"

For Pharo 5, we should move these extensions to Pharo.

Isn't it the case that a remove* methods mostly return what has been removed? Wouldn't be

withoutPrefix:
withoutSuffix:

a good alternative?

my 2 cents,

Norbert

Cheers,
Doru


On Mon, Apr 6, 2015 at 12:51 PM, Norbert Hartl <[hidden email]> wrote:
If you have the amount auf characters you want to omit you can do

'BormParticipant' allButFirst: 4

Norbert

> Am 06.04.2015 um 12:34 schrieb Peter Uhnák <[hidden email]>:
>
> Hi,
>
> am I really blind, or is there no way to do something like
> 'BormParticipant' removePrefix: 'Borm' "-> 'Participant'"
> or
> 'BormParticipant' copyFrom: 5 "-> 'Participant'" "OrderedCollection knows this"
>
> I can do copyFrom:to:, but that requires asking the size of the string, which is (in my eyes) ugly.
>
> So is there better (=single message) way?
>
> Thanks,
> Peter





--

"Every thing has its own flow"

Reply | Threaded
Open this post in threaded view
|

Re: String operations

Peter Uhnak

'BormParticipant' allButFirst: 4
('BormParticipant' splitOn: 'Borm') last
Thank you both, this will work. :)

In the Moose configuration, there is a CollectionExtensions that allows you to do this:
'BormParticipant' removePrefix: 'Borm' "-> 'Participant'".
'BormParticipant' removeSuffix: 'Participant' "-> 'Borm'"

For Pharo 5, we should move these extensions to Pharo.

Isn't it the case that a remove* methods mostly return what has been removed? Wouldn't be

withoutPrefix:
withoutSuffix:
I guess withoutPrefix: would probably makes more sense.

Thanks,
Peter
Reply | Threaded
Open this post in threaded view
|

Re: String operations

NorbertHartl

Am 07.04.2015 um 21:31 schrieb Peter Uhnák <[hidden email]>:


'BormParticipant' allButFirst: 4
('BormParticipant' splitOn: 'Borm') last
Thank you both, this will work. :)

In the Moose configuration, there is a CollectionExtensions that allows you to do this:
'BormParticipant' removePrefix: 'Borm' "-> 'Participant'".
'BormParticipant' removeSuffix: 'Participant' "-> 'Borm'"

For Pharo 5, we should move these extensions to Pharo.

Isn't it the case that a remove* methods mostly return what has been removed? Wouldn't be

withoutPrefix:
withoutSuffix:
I guess withoutPrefix: would probably makes more sense.

As well as

allButPrefix:
allButSuffix:

but to me the sound of them is weird.

Norbert

Reply | Threaded
Open this post in threaded view
|

Re: String operations

Damien Pollet-2
Indeed, there is much to say about the String API :)
Thanks for mentioning this, I'm gathering missing behavior like this !

On 8 April 2015 at 17:56, Norbert Hartl <[hidden email]> wrote:

Am 07.04.2015 um 21:31 schrieb Peter Uhnák <[hidden email]>:


'BormParticipant' allButFirst: 4
('BormParticipant' splitOn: 'Borm') last
Thank you both, this will work. :)

In the Moose configuration, there is a CollectionExtensions that allows you to do this:
'BormParticipant' removePrefix: 'Borm' "-> 'Participant'".
'BormParticipant' removeSuffix: 'Participant' "-> 'Borm'"

For Pharo 5, we should move these extensions to Pharo.

Isn't it the case that a remove* methods mostly return what has been removed? Wouldn't be

withoutPrefix:
withoutSuffix:
I guess withoutPrefix: would probably makes more sense.

As well as

allButPrefix:
allButSuffix:

but to me the sound of them is weird.

Norbert


Reply | Threaded
Open this post in threaded view
|

Re: String operations

Sean P. DeNigris
Administrator
Damien Pollet-2 wrote
Indeed, there is much to say about the String API :)
Thanks for mentioning this, I'm gathering missing behavior like this !
It seems unanimous that we should add these. I agree that they are useful in some cases. However, strings are so general that IMHO there are infinite such operations that we could add. Already "String methodDict size = 333", and one can't depend on method protocols to sort things out because they are hijacked for package extensions, so it's easy to be fooled by thinking "let me check the converting protocol for that" and (maybe) finding out later that you missed it because #asXyz is in *OtherPackage, which now forces you to manually scroll through 333 methods to make sure your desired message hasn't been implemented.

So I'm not saying "don't add them". I just want to have a conversation about:
1. How often would these be needed? (We should have that conversation about most of String's methods)
2. Do we have any plans for real protocols, with the concepts of privacy and package extension extracted into other objects where they belong?
3. In the mean time, what is a reasonable cognitive limit for an API? For me 333 is way beyond comprehension with the current tooling, crippled somewhat by #2.
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: String operations

S Krish

Perfectly stated..!

btw, I really liked the python string API's when I worked with them. simple, intuitive but effective in nearly all that I needed in it.



On Thu, Apr 9, 2015 at 12:59 PM, Sean P. DeNigris <[hidden email]> wrote:
Damien Pollet-2 wrote
> Indeed, there is much to say about the String API :)
> Thanks for mentioning this, I'm gathering missing behavior like this !

It seems unanimous that we should add these. I agree that they are useful in
some cases. However, strings are so general that IMHO there are infinite
such operations that we could add. Already "String methodDict size = 333",
and one can't depend on method protocols to sort things out because they are
hijacked for package extensions, so it's easy to be fooled by thinking "let
me check the converting protocol for that" and (maybe) finding out later
that you missed it because #asXyz is in *OtherPackage, which now forces you
to manually scroll through 333 methods to make sure your desired message
hasn't been implemented.

So I'm not saying "don't add them". I just want to have a conversation
about:
1. How often would these be needed? (We should have that conversation about
most of String's methods)
2. Do we have any plans for real protocols, with the concepts of privacy and
package extension extracted into other objects where they belong?
3. In the mean time, what is a reasonable cognitive limit for an API? For me
333 is way beyond comprehension with the current tooling, crippled somewhat
by #2.



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/String-operations-tp4817803p4818540.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: String operations

stepharo
In reply to this post by Tudor Girba-2
+ 1 :)

can you open a bug entry and I prefer withoutPrefix:, withoutSuffix:

Stef

Le 6/4/15 21:28, Tudor Girba a écrit :
In the Moose configuration, there is a CollectionExtensions that allows you to do this:
'BormParticipant' removePrefix: 'Borm' "-> 'Participant'".
'BormParticipant' removeSuffix: 'Participant' "-> 'Borm'"

For Pharo 5, we should move these extensions to Pharo.

Cheers,
Doru


On Mon, Apr 6, 2015 at 12:51 PM, Norbert Hartl <[hidden email]> wrote:
If you have the amount auf characters you want to omit you can do

'BormParticipant' allButFirst: 4

Norbert

> Am 06.04.2015 um 12:34 schrieb Peter Uhnák <[hidden email]>:
>
> Hi,
>
> am I really blind, or is there no way to do something like
> 'BormParticipant' removePrefix: 'Borm' "-> 'Participant'"
> or
> 'BormParticipant' copyFrom: 5 "-> 'Participant'" "OrderedCollection knows this"
>
> I can do copyFrom:to:, but that requires asking the size of the string, which is (in my eyes) ugly.
>
> So is there better (=single message) way?
>
> Thanks,
> Peter





--

"Every thing has its own flow"

Reply | Threaded
Open this post in threaded view
|

Re: String operations

stepharo
In reply to this post by Sean P. DeNigris
Hi sean

with damien we are restarting to work on analysing String API.
We would like to have it much more regular. We will finish a first small
articles
summarizing our analysis and send it around.

Stef

Le 9/4/15 12:59, Sean P. DeNigris a écrit :

> Damien Pollet-2 wrote
>> Indeed, there is much to say about the String API :)
>> Thanks for mentioning this, I'm gathering missing behavior like this !
> It seems unanimous that we should add these. I agree that they are useful in
> some cases. However, strings are so general that IMHO there are infinite
> such operations that we could add. Already "String methodDict size = 333",
> and one can't depend on method protocols to sort things out because they are
> hijacked for package extensions, so it's easy to be fooled by thinking "let
> me check the converting protocol for that" and (maybe) finding out later
> that you missed it because #asXyz is in *OtherPackage, which now forces you
> to manually scroll through 333 methods to make sure your desired message
> hasn't been implemented.
>
> So I'm not saying "don't add them". I just want to have a conversation
> about:
> 1. How often would these be needed? (We should have that conversation about
> most of String's methods)
> 2. Do we have any plans for real protocols, with the concepts of privacy and
> package extension extracted into other objects where they belong?
> 3. In the mean time, what is a reasonable cognitive limit for an API? For me
> 333 is way beyond comprehension with the current tooling, crippled somewhat
> by #2.
>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/String-operations-tp4817803p4818540.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: String operations

Henrik Sperre Johansen
In reply to this post by Sean P. DeNigris
+1.
In addition, half the methods you usually look for is actually implemented in their proper place (that is, SequenceableCollection, not String).

Cheers,
Henry

> On 09 Apr 2015, at 12:59 , Sean P. DeNigris <[hidden email]> wrote:
>
> Damien Pollet-2 wrote
>> Indeed, there is much to say about the String API :)
>> Thanks for mentioning this, I'm gathering missing behavior like this !
>
> It seems unanimous that we should add these. I agree that they are useful in
> some cases. However, strings are so general that IMHO there are infinite
> such operations that we could add. Already "String methodDict size = 333",
> and one can't depend on method protocols to sort things out because they are
> hijacked for package extensions, so it's easy to be fooled by thinking "let
> me check the converting protocol for that" and (maybe) finding out later
> that you missed it because #asXyz is in *OtherPackage, which now forces you
> to manually scroll through 333 methods to make sure your desired message
> hasn't been implemented.
>
> So I'm not saying "don't add them". I just want to have a conversation
> about:
> 1. How often would these be needed? (We should have that conversation about
> most of String's methods)
> 2. Do we have any plans for real protocols, with the concepts of privacy and
> package extension extracted into other objects where they belong?
> 3. In the mean time, what is a reasonable cognitive limit for an API? For me
> 333 is way beyond comprehension with the current tooling, crippled somewhat
> by #2.
>
>
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/String-operations-tp4817803p4818540.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: String operations

Tudor Girba-2
In reply to this post by stepharo
Great. I am interested in providing feedback.

Doru

On Thu, Apr 9, 2015 at 3:34 PM, stepharo <[hidden email]> wrote:
Hi sean

with damien we are restarting to work on analysing String API.
We would like to have it much more regular. We will finish a first small articles
summarizing our analysis and send it around.

Stef

Le 9/4/15 12:59, Sean P. DeNigris a écrit :

Damien Pollet-2 wrote
Indeed, there is much to say about the String API :)
Thanks for mentioning this, I'm gathering missing behavior like this !
It seems unanimous that we should add these. I agree that they are useful in
some cases. However, strings are so general that IMHO there are infinite
such operations that we could add. Already "String methodDict size = 333",
and one can't depend on method protocols to sort things out because they are
hijacked for package extensions, so it's easy to be fooled by thinking "let
me check the converting protocol for that" and (maybe) finding out later
that you missed it because #asXyz is in *OtherPackage, which now forces you
to manually scroll through 333 methods to make sure your desired message
hasn't been implemented.

So I'm not saying "don't add them". I just want to have a conversation
about:
1. How often would these be needed? (We should have that conversation about
most of String's methods)
2. Do we have any plans for real protocols, with the concepts of privacy and
package extension extracted into other objects where they belong?
3. In the mean time, what is a reasonable cognitive limit for an API? For me
333 is way beyond comprehension with the current tooling, crippled somewhat
by #2.



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/String-operations-tp4817803p4818540.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.







--

"Every thing has its own flow"
Reply | Threaded
Open this post in threaded view
|

Re: String operations

stepharo
It will be a first "draft"

Stef

Le 9/4/15 22:07, Tudor Girba a écrit :
Great. I am interested in providing feedback.

Doru

On Thu, Apr 9, 2015 at 3:34 PM, stepharo <[hidden email]> wrote:
Hi sean

with damien we are restarting to work on analysing String API.
We would like to have it much more regular. We will finish a first small articles
summarizing our analysis and send it around.

Stef

Le 9/4/15 12:59, Sean P. DeNigris a écrit :

Damien Pollet-2 wrote
Indeed, there is much to say about the String API :)
Thanks for mentioning this, I'm gathering missing behavior like this !
It seems unanimous that we should add these. I agree that they are useful in
some cases. However, strings are so general that IMHO there are infinite
such operations that we could add. Already "String methodDict size = 333",
and one can't depend on method protocols to sort things out because they are
hijacked for package extensions, so it's easy to be fooled by thinking "let
me check the converting protocol for that" and (maybe) finding out later
that you missed it because #asXyz is in *OtherPackage, which now forces you
to manually scroll through 333 methods to make sure your desired message
hasn't been implemented.

So I'm not saying "don't add them". I just want to have a conversation
about:
1. How often would these be needed? (We should have that conversation about
most of String's methods)
2. Do we have any plans for real protocols, with the concepts of privacy and
package extension extracted into other objects where they belong?
3. In the mean time, what is a reasonable cognitive limit for an API? For me
333 is way beyond comprehension with the current tooling, crippled somewhat
by #2.



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/String-operations-tp4817803p4818540.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.







--

"Every thing has its own flow"