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 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 <cdu...@apple.com> 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 <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. >>>> 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