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

2015-01-30 Thread Chris Dumez
Hi,

I made the changes in:



Kr,
--
Chris Dumez - Apple Inc.
Cupertino, CA




> On Jan 29, 2015, at 10:23 AM, Chris Dumez  wrote:
> 
> Hi all,
> 
> Thanks for the feedback.
> 
> I submitted a coding style update proposal at Bug 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 code unless there is any 
> objection.
> 
> Kr,
> --
> Chris Dumez - Apple Inc.
> Cupertino, CA
> 
> 
> 
> 
>> On Jan 28, 2015, at 9:26 PM, Ryosuke Niwa > > wrote:
>> 
>> On Wed, Jan 28, 2015 at 9:19 PM, Maciej Stachowiak > > 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 interpret Class::instance() to mean “create a brand new instance of 
>> this class” rather than “return the unique singleton instance of this class, 
>> creating if necessary".
>> 
>> Agreed.  I also prefer Class::singleton() over Class::instance().
>> 
>> - R. Niwa
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org 
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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 
.
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 code unless there is any 
objection.

Kr,
--
Chris Dumez - Apple Inc.
Cupertino, CA




> On Jan 28, 2015, at 9:26 PM, Ryosuke Niwa  wrote:
> 
> On Wed, Jan 28, 2015 at 9:19 PM, Maciej Stachowiak  > 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 interpret Class::instance() to mean “create a brand new instance of 
> this class” rather than “return the unique singleton instance of this class, 
> creating if necessary".
> 
> Agreed.  I also prefer Class::singleton() over Class::instance().
> 
> - R. Niwa
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  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 interpret Class::instance() to mean "create a brand new
> instance of this class" rather than "return the unique singleton instance
> of this class, creating if necessary".
>

Agreed.  I also prefer Class::singleton() over Class::instance().

- R. Niwa
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  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 interpret Class::instance() to mean “create a brand new instance of 
> this class” rather than “return the unique singleton instance of this class, 
> creating if necessary".
> 
> Regards,
> Maciej
> 
>> On Jan 28, 2015, at 8:54 PM, Chris Dumez  wrote:
>> 
>> 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  
>>> wrote:
>>> 
 On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak  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 me.
>>> 
>>> I recommend Class::instance(), which is what I've seen used almost 
>>> exclusively outside of WebKit. It's what Scott Meyers used, and it's very 
>>> similar to the Gang of Four's choice of Class::Instance() and the Java 
>>> pattern Class.INSTANCE.
>>> 
>>> That said, Class::singleton() is very attractive too.
>>> 
>>> I've never seen Class::shared() used anywhere except WebKit. The first time 
>>> I saw this I had no clue what it was until I looked up the implementation.
>>> 
>>> All of these can get quite annoying to type, especially when the name of 
>>> the class is long. (Sometimes I will keep a reference to the instance in a 
>>> local variable with a shorter name.) But I think they're easier to read 
>>> than free functions, and we should optimize for reading code, not writing 
>>> it. Not a big deal either way.
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev
>> 
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  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 interpret Class::instance() to mean “create a brand new instance of 
> this class” rather than “return the unique singleton instance of this class, 
> creating if necessary".
> 
> Regards,
> Maciej
> 
>> On Jan 28, 2015, at 8:54 PM, Chris Dumez > > wrote:
>> 
>> 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 >> > wrote:
>>> 
>>> On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak >> > 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 me.
>>> 
>>> I recommend Class::instance(), which is what I've seen used almost 
>>> exclusively outside of WebKit. It's what Scott Meyers used, and it's very 
>>> similar to the Gang of Four's choice of Class::Instance() and the Java 
>>> pattern Class.INSTANCE.
>>> 
>>> That said, Class::singleton() is very attractive too.
>>> 
>>> I've never seen Class::shared() used anywhere except WebKit. The first time 
>>> I saw this I had no clue what it was until I looked up the implementation.
>>> 
>>> All of these can get quite annoying to type, especially when the name of 
>>> the class is long. (Sometimes I will keep a reference to the instance in a 
>>> local variable with a shorter name.) But I think they're easier to read 
>>> than free functions, and we should optimize for reading code, not writing 
>>> it. Not a big deal either way.
>>> ___
>>> webkit-dev mailing list
>>> webkit-dev@lists.webkit.org 
>>> https://lists.webkit.org/mailman/listinfo/webkit-dev 
>>> 
>> 
> 

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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 class” rather 
than “return the unique singleton instance of this class, creating if 
necessary".

Regards,
Maciej

> On Jan 28, 2015, at 8:54 PM, Chris Dumez  wrote:
> 
> 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 > > wrote:
>> 
>> On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak > > 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 me.
>> 
>> I recommend Class::instance(), which is what I've seen used almost 
>> exclusively outside of WebKit. It's what Scott Meyers used, and it's very 
>> similar to the Gang of Four's choice of Class::Instance() and the Java 
>> pattern Class.INSTANCE.
>> 
>> That said, Class::singleton() is very attractive too.
>> 
>> I've never seen Class::shared() used anywhere except WebKit. The first time 
>> I saw this I had no clue what it was until I looked up the implementation.
>> 
>> All of these can get quite annoying to type, especially when the name of the 
>> class is long. (Sometimes I will keep a reference to the instance in a local 
>> variable with a shorter name.) But I think they're easier to read than free 
>> functions, and we should optimize for reading code, not writing it. Not a 
>> big deal either way.
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org 
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> 

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  wrote:
> 
> On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak  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 me.
> 
> I recommend Class::instance(), which is what I've seen used almost 
> exclusively outside of WebKit. It's what Scott Meyers used, and it's very 
> similar to the Gang of Four's choice of Class::Instance() and the Java 
> pattern Class.INSTANCE.
> 
> That said, Class::singleton() is very attractive too.
> 
> I've never seen Class::shared() used anywhere except WebKit. The first time I 
> saw this I had no clue what it was until I looked up the implementation.
> 
> All of these can get quite annoying to type, especially when the name of the 
> class is long. (Sometimes I will keep a reference to the instance in a local 
> variable with a shorter name.) But I think they're easier to read than free 
> functions, and we should optimize for reading code, not writing it. Not a big 
> deal either way.
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  wrote:
> 
> On Wed, Jan 28, 2015 at 8:11 PM, Maciej Stachowiak  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 me.
> 
> I recommend Class::instance(), which is what I've seen used almost 
> exclusively outside of WebKit. It's what Scott Meyers used, and it's very 
> similar to the Gang of Four's choice of Class::Instance() and the Java 
> pattern Class.INSTANCE.

I've seen this, also.  It's a good name.

> 
> That said, Class::singleton() is very attractive too.

:-)

> 
> I've never seen Class::shared() used anywhere except WebKit. The first time I 
> saw this I had no clue what it was until I looked up the implementation.

+1

> 
> All of these can get quite annoying to type, especially when the name of the 
> class is long. (Sometimes I will keep a reference to the instance in a local 
> variable with a shorter name.) But I think they're easier to read than free 
> functions, and we should optimize for reading code, not writing it. Not a big 
> deal either way.
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  
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 me.


I recommend Class::instance(), which is what I've seen used almost 
exclusively outside of WebKit. It's what Scott Meyers used, and it's 
very similar to the Gang of Four's choice of Class::Instance() and the 
Java pattern Class.INSTANCE.


That said, Class::singleton() is very attractive too.

I've never seen Class::shared() used anywhere except WebKit. The first 
time I saw this I had no clue what it was until I looked up the 
implementation.


All of these can get quite annoying to type, especially when the name 
of the class is long. (Sometimes I will keep a reference to the 
instance in a local variable with a shorter name.) But I think they're 
easier to read than free functions, and we should optimize for reading 
code, not writing it. Not a big deal either way.
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  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 Jan 28, 2015, at 6:11 PM, Maciej Stachowiak  wrote:
>> 
>> 
>>> On Jan 28, 2015, at 4:28 PM, Darin Adler  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 the member function approach.
>>> 
>>> It had always thought that we used static member functions for this to 
>>> replicate the pattern from Objective-C, and it seems more idiomatic modern 
>>> C++ to use a free function for this kind of thing.
>>> 
>>> Maciej’s point about Class::create() might be enough to convince me to 
>>> change my view, though; it’s hard to see any reason the same logic wouldn’t 
>>> apply in that case.
>> 
>> I would also find it acceptable to use free functions for all these cases. 
>> Mostly it bugs me for them to be different - the singleton case is rarer, so 
>> it seems odd to treat it as especially conciseness-worthy.
>> 
>> 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 me.
>> 
>> Regards,
>> Maciej
>> 
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org
>> https://lists.webkit.org/mailman/listinfo/webkit-dev
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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

2015-01-28 Thread Yong Li
"Class::unique()" is one of the known names for singletons

Yong Li

From: Maciej Stachowiak<mailto:m...@apple.com>
Sent: ‎1/‎28/‎2015 9:11 PM
To: Darin Adler<mailto:da...@apple.com>
Cc: WebKit Development<mailto:webkit-dev@lists.webkit.org>
Subject: Re: [webkit-dev] Pattern for singleton classes instance getters


> On Jan 28, 2015, at 4:28 PM, Darin Adler  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 the member function approach.
>
> It had always thought that we used static member functions for this to 
> replicate the pattern from Objective-C, and it seems more idiomatic modern 
> C++ to use a free function for this kind of thing.
>
> Maciej’s point about Class::create() might be enough to convince me to change 
> my view, though; it’s hard to see any reason the same logic wouldn’t apply in 
> that case.

I would also find it acceptable to use free functions for all these cases. 
Mostly it bugs me for them to be different - the singleton case is rarer, so it 
seems odd to treat it as especially conciseness-worthy.

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 me.

Regards,
Maciej

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  wrote:
> 
> 
>> On Jan 28, 2015, at 4:28 PM, Darin Adler  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 the member function approach.
>> 
>> It had always thought that we used static member functions for this to 
>> replicate the pattern from Objective-C, and it seems more idiomatic modern 
>> C++ to use a free function for this kind of thing.
>> 
>> Maciej’s point about Class::create() might be enough to convince me to 
>> change my view, though; it’s hard to see any reason the same logic wouldn’t 
>> apply in that case.
> 
> I would also find it acceptable to use free functions for all these cases. 
> Mostly it bugs me for them to be different - the singleton case is rarer, so 
> it seems odd to treat it as especially conciseness-worthy.
> 
> 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 me.
> 
> Regards,
> Maciej
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  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 the member function approach.
> 
> It had always thought that we used static member functions for this to 
> replicate the pattern from Objective-C, and it seems more idiomatic modern 
> C++ to use a free function for this kind of thing.
> 
> Maciej’s point about Class::create() might be enough to convince me to change 
> my view, though; it’s hard to see any reason the same logic wouldn’t apply in 
> that case.

I would also find it acceptable to use free functions for all these cases. 
Mostly it bugs me for them to be different - the singleton case is rarer, so it 
seems odd to treat it as especially conciseness-worthy.

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 me.

Regards,
Maciej

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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 static member functions for this to 
replicate the pattern from Objective-C, and it seems more idiomatic modern C++ 
to use a free function for this kind of thing.

Maciej’s point about Class::create() might be enough to convince me to change 
my view, though; it’s hard to see any reason the same logic wouldn’t apply in 
that case.

— Darin
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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  wrote:
> 
> Class::shared() pattern seems good to me.
> 
> - R. Niwa
> 
> On Wed, Jan 28, 2015 at 11:38 AM, Benjamin Poulain  > 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, Chris Dumez wrote:
>> Hi,
>> 
>> I noticed that we are currently not very consistent in WebKit in the way we 
>> implement singleton classes instance getters.
>> - Some classes use free functions (like MemoryCache, and PageCache until I 
>> updated it yesterday). e.g. memoryCache().xxx()
>> - Some classes are using static functions in the class (e.g. 
>> DatabaseProcess::shared(), PluginProcess::shared()).
>> 
>> As I said, I landed a patch yesterday so that the global page cache is now 
>> accessed via PageCache::shared() because I thought this was the currently 
>> preferred pattern (given it seems very common in WebKit2 code).
>> However, I thought I would email webkit-dev to make sure this is actually 
>> the case and make sure we agree on a given pattern (one way or another) for 
>> current and future code. We could then maybe document this
>> as part of our coding style.
>> 
>> Any feedback on this matter?
>> 
>> Kr,
>> --
>> Chris Dumez - Apple Inc.
>> Cupertino, CA
>> 
>> 
>> 
>> 
>> 
>> 
>> ___
>> webkit-dev mailing list
>> webkit-dev@lists.webkit.org 
>> https://lists.webkit.org/mailman/listinfo/webkit-dev 
>> 
> 
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org 
> https://lists.webkit.org/mailman/listinfo/webkit-dev 
> 
> 
> 
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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 
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, Chris Dumez wrote:
>
> Hi,
>
>  I noticed that we are currently not very consistent in WebKit in the way
> we implement singleton classes instance getters.
> - Some classes use free functions (like MemoryCache, and PageCache until I
> updated it yesterday). e.g. memoryCache().xxx()
> - Some classes are using static functions in the class
> (e.g. DatabaseProcess::shared(), PluginProcess::shared()).
>
>  As I said, I landed a patch yesterday so that the global page cache is
> now accessed via PageCache::shared() because I thought this was the
> currently preferred pattern (given it seems very common in WebKit2 code).
> However, I thought I would email webkit-dev to make sure this is actually
> the case and make sure we agree on a given pattern (one way or another) for
> current and future code. We could then maybe document this
> as part of our coding style.
>
>  Any feedback on this matter?
>
>  Kr,
>  --
> Chris Dumez - Apple Inc.
> Cupertino, CA
>
>
>
>
>
>
> ___
> webkit-dev mailing 
> listwebkit-dev@lists.webkit.orghttps://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
>
> ___
> webkit-dev mailing list
> webkit-dev@lists.webkit.org
> https://lists.webkit.org/mailman/listinfo/webkit-dev
>
>
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


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 getters.
- Some classes use free functions (like MemoryCache, and PageCache 
until I updated it yesterday). e.g. memoryCache().xxx()
- Some classes are using static functions in the class 
(e.g. DatabaseProcess::shared(), PluginProcess::shared()).


As I said, I landed a patch yesterday so that the global page cache is 
now accessed via PageCache::shared() because I thought this was the 
currently preferred pattern (given it seems very common in WebKit2 code).
However, I thought I would email webkit-dev to make sure this is 
actually the case and make sure we agree on a given pattern (one way 
or another) for current and future code. We could then maybe document this

as part of our coding style.

Any feedback on this matter?

Kr,
--
Chris Dumez - Apple Inc.
Cupertino, CA






___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev


[webkit-dev] Pattern for singleton classes instance getters

2015-01-28 Thread Chris Dumez
Hi,

I noticed that we are currently not very consistent in WebKit in the way we 
implement singleton classes instance getters.
- Some classes use free functions (like MemoryCache, and PageCache until I 
updated it yesterday). e.g. memoryCache().xxx()
- Some classes are using static functions in the class (e.g. 
DatabaseProcess::shared(), PluginProcess::shared()).

As I said, I landed a patch yesterday so that the global page cache is now 
accessed via PageCache::shared() because I thought this was the currently 
preferred pattern (given it seems very common in WebKit2 code).
However, I thought I would email webkit-dev to make sure this is actually the 
case and make sure we agree on a given pattern (one way or another) for current 
and future code. We could then maybe document this
as part of our coding style.

Any feedback on this matter?

Kr,
--
Chris Dumez - Apple Inc.
Cupertino, CA




___
webkit-dev mailing list
webkit-dev@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-dev