Issue 7272 in pharo: String>>withoutTrailingDigits

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

Issue 7272 in pharo: String>>withoutTrailingDigits

pharo
Status: New
Owner: ----
Labels: Type-Bug

New issue 7272 by [hidden email]: String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Pharo1.4
Latest update: #14438

I think this is an old bug, String>>withoutTrailingDigits does not remove  
only the last digits of a string, but also the leading digits

To reproduce:
evaluate this:
'Whoo123pie234' withoutTrailingDigits

this also highlight the issue more:
  '123Whoopie' withoutTrailingDigits




_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #1 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Works in 2.0:

'Whoo123pie234' withoutTrailingDigits = 'Whoo'
'123pie234' withoutTrailingDigits = ''

which is what the comment says, confusing method name though. I would  
expect something more like:


'Whoo123pie234' withoutTrailingDigits = 'Whoo123pie'
'123pie234' withoutTrailingDigits = '123pie'



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #2 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Good catch !

But we have way too many methods on String that do very similar things.

Consider

   'foo123' trimRight: [ :each | each isDigit | each isSeparator ]

All these with/without methods could all be written like that.
We could reimplement them all, or remove even them ;-)

And we need more tests !

What do you think ?


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #3 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

>> We could reimplement them all, or remove even them ;-)

So I vote for removing what we can, rewriting the others and change this  
issue's title to: 'Clean withXXX and withoutXXX methods in String'.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #4 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Camillo,
  Yes I'm also expecting that 'Whoo123pie234' withoutTrailingDigits  
is 'Whoo123pie'
and '123pie234' withoutTrailingDigits is '123pie'

Anyway, it can be solved by recursion:

String>>brandNewWithoutTrailingDigits
    self last isDigit ifTrue: [^self allButLast  
brandNewWithoutTrailingDigits ] ifFalse:[^self]

Can someone add to the next milestone?


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #5 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

@ davide

Although elegant, that would be terribly inefficient ;-)

@ camillo

Somehow I was expecting you to say nuke them ;-)

On the other hand, right after I wrote it, I thought that unary selectors  
are very elegant. So the question becomes how much will these be used ?



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #6 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

@sven

:-) but efficiency is not an absolute metric, you should evaluate it with a  
profiler on hand. Otherwise Ruby shouldn't have been created :-D :-D :-D


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo
Updates:
        Status: Accepted

Comment #7 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Very funny !

OK, I am going to do a pass over these with/without methods and try to  
clean them a bit as well as add some tests.

Sven


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #8 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Another remark, consider the selectors #withoutTrailingDigits and  
#withoutJustTrailingDigits !

#withoutTrailingDigits removes digits and whitespace, so the proper name is  
#withoutTrailingDigitsOrWhitespace

Also, the unary selectors can be combined easily (and elegantly although  
inefficiently):

   'foo 123' withoutTrailingDigits trimRight.

so I don't think we need all of them.

Note that #withoutWrappingDoubleQuotes must die: it is plain wrong and  
there already is #withoutQuoting

I will make a new issue.



_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #9 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

http://code.google.com/p/pharo/issues/detail?id=7275

Sanitize String with/without selectors


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #10 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Can be closed/merged as there is now a slice for  
http://code.google.com/p/pharo/issues/detail?id=7275


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo
Updates:
        Status: Closed

Comment #11 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

(No comment was entered for this change.)


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker
Reply | Threaded
Open this post in threaded view
|

Re: Issue 7272 in pharo: String>>withoutTrailingDigits

pharo

Comment #12 on issue 7272 by [hidden email]:  
String>>withoutTrailingDigits
http://code.google.com/p/pharo/issues/detail?id=7272

Thanks guys!
I like this cool energy.


_______________________________________________
Pharo-bugtracker mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-bugtracker