Re: Singletons

From: Date: Wed, 05 Feb 2014 12:09:20 +0000
Subject: Re: Singletons
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-72267@lists.php.net to get a copy of this message
2014-02-05 Marco Pivetta <ocramius@gmail.com>: > On 5 February 2014 11:19, Kevin Ingwersen <ingwie2000@googlemail.com> > wrote: > > > Hello. ^^ > > > > I just wanted to ask, if there is a singleton implementation? The current > > one is rather "hackish", by using a static property, initializer and a > > function to itneract with it all. Sadly, I can not put a patch together > > myself - because I am not good with YACC and Flex yet, or with the php > vm - > > but i would have a concept for an implementation o.o > > > > Hi Kevin, > > I don't think that standardizing a well known anti-pattern in core is a > good idea. > The current static property approach is quite fine and safe to use (if you > really need it, which is "no" in 99.9999% of cases), and not hackish at > all. > Beside this: Thats how it works in all me known languages. I don't know any language, where a pattern (in any form) is part of the core. > > Cheers, > > Marco Pivetta > > http://twitter.com/Ocramius > > http://ocramius.github.com/ > -- github.com/KingCrunch

« previous php.internals (#72267) next »