Not so chicken and egg if, through reflection, a ReflectionClass object could 
inform all the instances of that class in a simple array or with an iterator.
May be there's another even better place where to implement such a 
functionality, i'm just pointing reflection because i think it's natural that 
a class should know what instances of itself are around there.

Regards
Leo

On Tuesday 10 May 2005 13:10, Wez Furlong wrote:
> 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 <[EMAIL PROTECTED]> wrote:
> > Yes, the question was pointed in another way, the destructors are not
> > called 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 loaded instance instead of creating an aliasing of that instance,
> > then you get the 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 check when references are removed in any way.
> > And leaving the array growing while each object that exists in a huge
> > database is slowly loaded and never unloaded, is not an option.
> >
> > Leo
> >
> > 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
> > > > impossible, 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 the array when all other references have gone, so they
> > > > never destruct, except when the array is destroyed at program's end.
> > >
> > > PHP5 has destructors ...
> > >
> > > regards,
> > > Lukas
> >
> > --
> >
> > Leonardo Pedretti
> > Axon Sistemas
> > Líder de Equipo Proyecto Basalto
> >
> > --
> > PHP Internals - PHP Runtime Development Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php

-- 

Leonardo Pedretti
Axon Sistemas
Líder de Equipo Proyecto Basalto

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to