Re: new overloading feature?

From: Date: Fri, 05 Nov 2004 17:10:09 +0000
Subject: Re: new overloading feature?
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-13733@lists.php.net to get a copy of this message
Andrey Hristov <php@hristov.com> 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

« previous php.internals (#13733) next »