There was a previous thread [1] that involved discussion of the naming convention for methods doing "dangerous" in-place mutatation - e.g. sort/sorted, reverse/reversed - and even though I now know there is such a naming convention, its hard to keep track of which is which. Now today I happened to be looking for the first time at some Ruby code and came across their naming convention for "dangerous" methods of having a trailing exclamation mark - e.g. sort/sort!, reverse/reverse! - which is REALLY intuitive. How extreme is it to wonder if Pharo might some day be able to support such a convention? [1] http://forum.world.st/11635-Race-condition-in-SequenceableCollection-gt-gt-s...
There was a previous thread [1] that involved discussion of the naming convention for methods doing "dangerous" in-place mutatation - e.g. sort/sorted, reverse/reversed - and even though I now know there is such a naming convention, its hard to keep track of which is which.
Now today I happened to be looking for the first time at some Ruby code and came across their naming convention for "dangerous" methods of having a trailing exclamation mark - e.g. sort/sort!, reverse/reverse! - which is REALLY intuitive. How extreme is it to wonder if Pharo might some day be able to support such a convention? You know we cannot change the world in one day. So I like this convention but did you measure how much work it would mean to follow it.
What would be good is to have systematically method comments to build tools to give some hints and to slowly make sure that we follow our convention. analyse what is reasonable to do. Stef
[1] http://forum.world.st/11635-Race-condition-in-SequenceableCollection-gt-gt-s...
From what I've seen of that convention in Ruby, it gets misused. They also have the convention of ending selectors with a question mark for predicates, which works quite well (besides the fact that it's hardcoded in the language⦠you can't do this, for instance, because only one of ? or ! can end the selector
def wtf??! return 42 end As for the ! indicating side-effects, there are methods with side effects that don't end in !, and some that don't really that have it. In the end, the meaning gets diluted, IMHO. In Smalltalk, we have method categories, I'd like to exploit them more than just see them in the browser. If we could use them as tags instead of as a partition, that would be more flexible too On 22 June 2014 19:23, stepharo <stepharo@free.fr> wrote:
There was a previous thread [1] that involved discussion of the naming convention for methods doing "dangerous" in-place mutatation - e.g. sort/sorted, reverse/reversed - and even though I now know there is such a naming convention, its hard to keep track of which is which.
Now today I happened to be looking for the first time at some Ruby code and came across their naming convention for "dangerous" methods of having a trailing exclamation mark - e.g. sort/sort!, reverse/reverse! - which is REALLY intuitive. How extreme is it to wonder if Pharo might some day be able to support such a convention?
You know we cannot change the world in one day. So I like this convention but did you measure how much work it would mean to follow it.
What would be good is to have systematically method comments to build tools to give some hints and to slowly make sure that we follow our convention. analyse what is reasonable to do.
Stef
[1] http://forum.world.st/11635-Race-condition-in-SequenceableCollection-gt-gt-s...
-- Damien Pollet type less, do more [ | ] http://people.untyped.org/damien.pollet
Not sure where the convention first arose, but definitely not in Ruby. Scheme (1975) used trailing ! for side-effect containing functions and ? for predicates. For example, see SICP [1]. [1] https://mitpress.mit.edu/sicp/full-text/book/book.html On Jun 22, 2014, at 09:13 , Ben Coman wrote:
There was a previous thread [1] that involved discussion of the naming convention for methods doing "dangerous" in-place mutatation - e.g. sort/sorted, reverse/reversed - and even though I now know there is such a naming convention, its hard to keep track of which is which. Now today I happened to be looking for the first time at some Ruby code and came across their naming convention for "dangerous" methods of having a trailing exclamation mark - e.g. sort/sort!, reverse/reverse! - which is REALLY intuitive. How extreme is it to wonder if Pharo might some day be able to support such a convention?
[1] http://forum.world.st/11635-Race-condition-in-SequenceableCollection-gt-gt-s...
participants (4)
-
Ben Coman -
Damien Pollet -
Douglas McPherson -
stepharo