Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:16204 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 57990 invoked by uid 1010); 10 May 2005 16:28:04 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 27239 invoked from network); 10 May 2005 16:10:56 -0000 Received: from unknown (HELO gmail.com) (127.0.0.1) by localhost with SMTP; 10 May 2005 16:10:56 -0000 X-Host-Fingerprint: 64.233.184.202 wproxy.gmail.com Linux 2.4/2.6 Received: from ([64.233.184.202:46367] helo=wproxy.gmail.com) by pb1.pair.com (ecelerity 1.2 r(5656M)) with SMTP id F7/FB-35155-E0DD0824 for ; Tue, 10 May 2005 12:10:54 -0400 Received: by wproxy.gmail.com with SMTP id 57so1747180wri for ; Tue, 10 May 2005 09:10:51 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=kp9oqZ5wcF4D+VnVfQ4LpMeOw83UyRL6j46DdfKJHmSAFt1+voExR05Mj/5RXa0V4IaIWxCPSvLLv/rS6ZG+A/pyD2fV4M801iJo4rhhCo1UcF7Df0UwQ34IkJOFld2aZQyUgWYYHokPLi0YfXIPid0R1GwLMYsuBlyoLW3UTsk= Received: by 10.54.7.16 with SMTP id 16mr585444wrg; Tue, 10 May 2005 09:10:51 -0700 (PDT) Received: by 10.54.77.4 with HTTP; Tue, 10 May 2005 09:10:50 -0700 (PDT) Message-ID: <4e89b4260505100910764d96c6@mail.gmail.com> Date: Tue, 10 May 2005 12:10:51 -0400 Reply-To: Wez Furlong To: lpedretti@suserver.com Cc: Lukas Smith , internals@lists.php.net In-Reply-To: <200505101148.56888.lpedretti@suserver.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200505091130.56300.lpedretti@suserver.com> <200505101046.19099.lpedretti@suserver.com> <4280C47B.2070507@php.net> <200505101148.56888.lpedretti@suserver.com> Subject: Re: [PHP-DEV] Re: [PHP] Re: [PHP-DEV] make new return a reference to existent object From: kingwez@gmail.com (Wez Furlong) Chicken and egg; you can't keep the object alive without a reference. There is no way to achieve what you want, and we're not going to change the behaviour of the new operator, nor are we going to build some kind of singleton factory thingy into the core language; you have the tools to do it "the right way", please use them and kill these two threads. --Wez. On 5/10/05, Leonardo Pedretti wrote: > Yes, the question was pointed in another way, the destructors are not cal= led > until the last reference to an object has been removed, but if you store = a > reference in an array so you lately return a reference to the already loa= ded > instance instead of creating an aliasing of that instance, then you get t= he > undesirable behavior that the object is never destroyed until the script > ends, because there is always a reference in that array and you can not c= heck > when references are removed in any way. > And leaving the array growing while each object that exists in a huge dat= abase > is slowly loaded and never unloaded, is not an option. >=20 > Leo >=20 > On Tuesday 10 May 2005 11:26, you wrote: > > Leonardo Pedretti wrote: > > > It would not be such a problem to write something that does the same = task > > > through a static or global function, but unfortunately it is impossib= le, > > > due to the following: you can build a cache in an array, then in a > > > __new() function you could check if the requested object is already > > > loaded and return a reference. However, if this is the case, objects = that > > > enter the cache never leave it because they are still referenced in t= he > > > array when all other references have gone, so they never destruct, ex= cept > > > when the array is destroyed at program's end. > > > > PHP5 has destructors ... > > > > regards, > > Lukas >=20 > -- >=20 > Leonardo Pedretti > Axon Sistemas > L=EDder de Equipo Proyecto Basalto >=20 > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >=20 >