Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-30 Thread Chris Dumez
Hi, I made the changes in: http://trac.webkit.org/changeset/179401 http://trac.webkit.org/changeset/179409 Kr, -- Chris Dumez - Apple Inc. Cupertino, CA On Jan 29, 2015, at 10:23 AM, Chris Dumez cdu...@apple.com wrote: Hi all, Thanks for the feedback. I submitted a coding style

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-29 Thread Chris Dumez
Hi all, Thanks for the feedback. I submitted a coding style update proposal at Bug 141040 https://bugs.webkit.org/show_bug.cgi?id=141040. Based on the mailing list feedback, the proposal is to use a static member function named singleton()”. I will also upload a patch to align our existing

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Maciej Stachowiak
Perhaps we should document this in the coding style guidelines. I like consistency and static member function seems like a good way to go, particularly since it matches the Class::create() pattern we often use for non-singletons. On Jan 28, 2015, at 12:10 PM, Ryosuke Niwa rn...@webkit.org

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Darin Adler
I like the economy of the smaller non-member function name; it seems overly wordy to be constantly stating the class name as well as the nearly meaningless word “shared”. I think the word “shared” is what I like least about the member function approach. It had always thought that we used

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Gavin Barraclough
Gotta say, ‘singleton’ seems like a really good name for singletons. G. On Jan 28, 2015, at 7:06 PM, Filip Pizlo fpi...@apple.com wrote: This is shorter: Class::singleton() It's also more consistent with the rest of our style (we usually don't put get in getter names). -Filip On

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Yong Li
] Pattern for singleton classes instance getters On Jan 28, 2015, at 4:28 PM, Darin Adler da...@apple.com wrote: I like the economy of the smaller non-member function name; it seems overly wordy to be constantly stating the class name as well as the nearly meaningless word “shared”. I think

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Filip Pizlo
This is shorter: Class::singleton() It's also more consistent with the rest of our style (we usually don't put get in getter names). -Filip On Jan 28, 2015, at 6:11 PM, Maciej Stachowiak m...@apple.com wrote: On Jan 28, 2015, at 4:28 PM, Darin Adler da...@apple.com wrote: I like the

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Maciej Stachowiak
On Jan 28, 2015, at 4:28 PM, Darin Adler da...@apple.com wrote: I like the economy of the smaller non-member function name; it seems overly wordy to be constantly stating the class name as well as the nearly meaningless word “shared”. I think the word “shared” is what I like least about

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Michael Catanzaro
On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak m...@apple.com wrote: Yet another possibility is finding a better name than ‘shared’ for the singleton pattern function, but I don’t have any better ideas. Class::getSingleton() is more explicit but the extra verbosity doesn’t seem helpful to

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Filip Pizlo
On Jan 28, 2015, at 8:44 PM, Michael Catanzaro mcatanz...@igalia.com wrote: On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak m...@apple.com wrote: Yet another possibility is finding a better name than ‘shared’ for the singleton pattern function, but I don’t have any better ideas.

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Chris Dumez
Yes, instance() is what I’ve seen mostly outside WebKit as well. This would be my preference. Kr, -- Chris Dumez - Apple Inc. Cupertino, CA On Jan 28, 2015, at 8:44 PM, Michael Catanzaro mcatanz...@igalia.com wrote: On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak m...@apple.com wrote:

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Maciej Stachowiak
This may be a question of what jargon we’ve encountered, but to me, “singleton clearly means the one unique instance of this class while “instance means any instance of this class. If I hadn’t seen this thread, I would interpret Class::instance() to mean “create a brand new instance of this

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Chris Dumez
Fair enough, singleton() is very explicit indeed. I would be happy with this naming too. -- Chris Dumez - Apple Inc. Cupertino, CA On Jan 28, 2015, at 9:19 PM, Maciej Stachowiak m...@apple.com wrote: This may be a question of what jargon we’ve encountered, but to me, “singleton clearly

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Timothy Hatcher
Yeah, that is exactly what I was thinking. Instance does not imply only one like singleton does. Call a singleton a singleton, we have a word for it. — Timothy Hatcher On Jan 28, 2015, at 9:19 PM, Maciej Stachowiak m...@apple.com wrote: This may be a question of what jargon we’ve

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Ryosuke Niwa
On Wed, Jan 28, 2015 at 9:19 PM, Maciej Stachowiak m...@apple.com wrote: This may be a question of what jargon we've encountered, but to me, singleton clearly means the one unique instance of this class while instance means any instance of this class. If I hadn't seen this thread, I would

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Benjamin Poulain
IMHO, scoping the function by its class is cleaner. http://trac.webkit.org/changeset/179247 looks like an improvement to me. Benjamin On 1/28/15 11:30 AM, Chris Dumez wrote: Hi, I noticed that we are currently not very consistent in WebKit in the way we implement singleton classes instance

Re: [webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Ryosuke Niwa
Class::shared() pattern seems good to me. - R. Niwa On Wed, Jan 28, 2015 at 11:38 AM, Benjamin Poulain benja...@webkit.org wrote: IMHO, scoping the function by its class is cleaner. http://trac.webkit.org/changeset/179247 looks like an improvement to me. Benjamin On 1/28/15 11:30 AM,