Hi, Am 2011-02-16 um 10:24 schrieb Nicolas Cellier:
I started referencing Smalltalk idioms at http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_fun...) I could have focused on ANSI but have chosen Squeak/Pharo. Feel free to correct me and to complete me.
This is a very enlighting exercize, especially for pointing when API turns to be not that bright. During my perigrination, I notably noticed this:
#compare: returns 1, 2, or 3 : this is both very object oriented, very intuitive and very standard and the rest of the world is stupid, unless...
#findLastOccurrenceOfString:startingAt: in its current form is stupid to my taste, because 1) implementation is inefficient 2) the startingAt: only skip the beginning of the string which seems odd for a rfind operation I would rather expect this kind of usage: last := aString findLastOccurrenceOfString: 'to' startingAt: aString size. lastButOne := aString findLastOccurrenceOfString: 'to' startingAt: last - 1.
The CamelCase is sometimes abusive like #includesSubString:
While Iâm with you in the preceding part, the following is incorrect:
There is no format. I know, purists will tell me that encoding a format in a cryptic string is not in the Smalltalk spirit, but please then tell me how to specify a formatting efficiently and also remove cryptic regex encoding (a pity, it's not in trunk).
see String>>format: "format the receiver with aCollection simplest example: 'foo {1} bar' format: {Date today}. complete example: '\{ \} \\ foo {1} bar {2}' format: {12. 'string'}. " as well as the String>>expandMacros* methods. The latter seem more elaborate but unused, however. So Long, -Tobias