Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13734 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76722 invoked by uid 1010); 5 Nov 2004 17:17:40 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 76697 invoked from network); 5 Nov 2004 17:17:40 -0000 Received: from unknown (HELO iko.gotobg.net) (80.168.8.116) by pb1.pair.com with SMTP; 5 Nov 2004 17:17:40 -0000 Received: from pd9519cba.dip.t-dialin.net ([217.81.156.186] helo=[192.168.0.36]) by iko.gotobg.net with esmtpa (Exim 4.43) id 1CQ7iZ-0006hD-6s; Fri, 05 Nov 2004 19:17:43 +0200 Message-ID: <418BB509.1080207@hristov.com> Date: Fri, 05 Nov 2004 18:14:49 +0100 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a5) Gecko/20041102 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Derrell.Lipman@UnwiredUniverse.com CC: internals References: <418BAA16.6020602@hristov.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - iko.gotobg.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - hristov.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] new overloading feature? From: php@hristov.com (Andrey Hristov) Derrell.Lipman@UnwiredUniverse.com wrote: > Andrey Hristov writes: > > >> Why not using Singleton for multiple objects with getInstance() ? > > > Yeah, it's not quite a Singleton pattern. I've seen references to what I'm > talking about as a Pool pattern. That's basically what I described here: > Yes, Pool. I just said that it is Singleton for multiple objects which in fact is pool. >>>One could certainly call a function which searched for the key value and >>>only instantiated a new object if the existing one was not found, but this >>>seems cleaner. > > > There are absolutely ways to do this purely at the application level. It just > seems that it'd be a really clean, easy to program, easy to understand > methodology to pass the key value to the request for a new instance, and get > back either a new instance, or a previously existing one with that key value. > > In fact, the proposed __new() feature could provide an automatic Singleton > capability without the caller needing to worry about (or even know) that it's > dealing with a Singleton. The class defines a __new() function that always > returns its one and only instance (instantiating it the very first time), and > the application can always use 'new' without worrying about the internal > implementation. > > Derrell > The thing I find nice in the current way of implementing it with getInstance() and a static class variable is that it is like it is defined in GoF. People can easily understand what's going on. Otherwise it is too much of magic to me:) Andrey