Peter Hodge wrote: > You should just need to: > - add T_SINGLETON to the parser. > - add an is_singleton flag for class definitions, activated by T_SINGLETON. > - overload the 'new' operator to retrieve from the hash table if the class is > a > singleton (otherwise call __construct() as normal). > - implement some of those helper functions such as singleton_getobjects().
Hi, This seems both to be excessively magical and inflexible. For instance, I have implemented global singletons, singleton per-configuration path (i.e. for a configuration object with cascading configuration files, one singleton per configuration file location), and other models for singleton that stray on the continuum between singleton and factory. The proposed implementation allows only the textbook singleton. The benefit of having singleton in the zend engine in my book is zero. If you have 10 gazillion classes that are all singletons, perhaps another look at the design is in order? I've never had to singleton-ize more than 2-3 classes in even the most complex projects I've been involved with. Greg -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php