On 21 jan 2007 Lars Schultz wrote:
> >Perhaps you could use your own reference counting?
> >Keep your "real" objects in private array and instead of returning them
> > return a simple object which would forward all methods and properties by
> > __get/__set/__call. The constructor would increase your internal refcount
> > by one, destructor would decrease it.
>
> I use those objects quite often as they are used to access the database
> to manipulate or search for related data. It wouldn't perform well and
> is actually not at all practicable because there are so many classes for
> which I'd would have to copy the interface.

I don't see any place where you'd have to change the interface - except for 
the class which contains that private array; you can use the name of your 
current  class (MyObject)as the name of this new "forwarding" class and make a 
new name for the class which would be a copy of your current class (eg. 
MyObject_private). Therefore in all function definitions required class 
specification doesn't need to change.

Well, perhaps you would have to change some "factory" class if you use one, 
but that should be a one place - if you kept your code clean.


I think this solution is better, as you don't have to rely on internal 
refcounts, which can be implemented in another way (or dropped altogether) in 
future releases.

-- 
Paweł Stradomski

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

Reply via email to