Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:13733 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49941 invoked by uid 1010); 5 Nov 2004 17:10:11 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 49858 invoked from network); 5 Nov 2004 17:10:10 -0000 Received: from unknown (HELO amber.vis-av.com) (66.92.75.243) by pb1.pair.com with SMTP; 5 Nov 2004 17:10:10 -0000 Received: (qmail 23260 invoked from network); 5 Nov 2004 17:10:10 -0000 Received: from unknown (HELO random.?none?) (192.168.1.9) by amber.internal with SMTP; 5 Nov 2004 17:10:10 -0000 Received: (nullmailer pid 18536 invoked by uid 0); Fri, 05 Nov 2004 17:10:10 -0000 To: Andrey Hristov Cc: internals References: <418BAA16.6020602@hristov.com> Reply-To: Derrell.Lipman@UnwiredUniverse.com Date: Fri, 05 Nov 2004 12:10:09 -0500 In-Reply-To: <418BAA16.6020602@hristov.com> (Andrey Hristov's message of "Fri, 05 Nov 2004 17:28:06 +0100") Message-ID: User-Agent: Gnus/5.110003 (No Gnus v0.3) XEmacs/21.4 (Common Lisp, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [PHP-DEV] new overloading feature? From: Derrell.Lipman@UnwiredUniverse.com 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: >> 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