[PHP-DEV] weak references

2011-07-14 Thread Ferenc Kovacs
To spare the "5.4 features vote" thread from the off-topic discussion, we can continue here. Hannes Landeholm brought this idea up, see http://news.php.net/php.internals/53956 and http://news.php.net/php.internals/53959 I would suggest that Hannes create an rfc, and add some examples and introduce

Re: [PHP-DEV] weak references

2011-07-15 Thread Etienne Kneuss
Hi, On Thu, Jul 14, 2011 at 21:42, Ferenc Kovacs wrote: > To spare the "5.4 features vote" thread from the off-topic discussion, > we can continue here. > Hannes Landeholm brought this idea up, see > http://news.php.net/php.internals/53956 and > http://news.php.net/php.internals/53959 > I would s

Re: [PHP-DEV] weak references

2011-07-15 Thread Hannes Landeholm
Hi, Ferenc: Good idea to move the discussion to a separate thread. Etienne: Awesome. I wish I had time to write the patch myself. I could probably put some hours into adding more details to the RFC though. The only problem as I see it by making it a weak reference class instead of a weak referen

Re: [PHP-DEV] weak references

2011-07-16 Thread Hannes Landeholm
Hello, I just realized you could actually utilize the __destruct method to catch the event I described in my last post. The SplWeakRef class as currently defined in the RFC would therefore suffice to build a userland class that automatically garbage collects indexes. ~Hannes

Re: [PHP-DEV] weak references

2011-07-16 Thread Hannes Landeholm
I was going to add some content to https://wiki.php.net/rfc/weakreferencesnow but the wiki tells me that the page is read only for me. I couldn't find any details on who to contact to change this. ~Hannes

Re: [PHP-DEV] weak references

2011-07-16 Thread Richard Quadling
On 14 July 2011 20:42, Ferenc Kovacs wrote: > To spare the "5.4 features vote" thread from the off-topic discussion, > we can continue here. > Hannes Landeholm brought this idea up, see > http://news.php.net/php.internals/53956 and > http://news.php.net/php.internals/53959 > I would suggest that H

Re: [PHP-DEV] weak references

2011-07-16 Thread Ferenc Kovacs
On Sat, Jul 16, 2011 at 12:14 PM, Richard Quadling wrote: > On 14 July 2011 20:42, Ferenc Kovacs wrote: >> To spare the "5.4 features vote" thread from the off-topic discussion, >> we can continue here. >> Hannes Landeholm brought this idea up, see >> http://news.php.net/php.internals/53956 and >

Re: [PHP-DEV] weak references

2011-07-16 Thread Ferenc Kovacs
On Sat, Jul 16, 2011 at 12:11 PM, Hannes Landeholm wrote: > I was going to add some content to > https://wiki.php.net/rfc/weakreferencesnow but the wiki tells me that > the page is read only for me. I couldn't find > any details on who to contact to change this. > > ~Hannes > I already asked bjor

Re: [PHP-DEV] weak references

2011-07-16 Thread Hannes Landeholm
Since Weak references is already an established concept in many OOP languages a lot can be learned from their implementation. A lot of the potential related problems and solutions has already been studied. Anyone who wish to contribute to this feature should start by reading this excellent article

Re: [PHP-DEV] weak references

2011-07-16 Thread Ferenc Kovacs
On Sat, Jul 16, 2011 at 1:13 PM, Hannes Landeholm wrote: > Since Weak references is already an established concept in many OOP > languages a lot can be learned from their implementation. A lot of the > potential related problems and solutions has already been studied. > Anyone who wish to contribu

Re: [PHP-DEV] weak references

2011-07-16 Thread Hannes Landeholm
I'm not familiar with the internal implementation of GC in PHP but if the current garbage collection implementation makes catching the gc event non-trivial I'd agree and vote for postponing my "SplQueue ref_queue" suggestion until the future. It could always be added later and there is the temporar

Re: [PHP-DEV] weak references

2011-07-17 Thread Ferenc Kovacs
On Sat, Jul 16, 2011 at 12:11 PM, Hannes Landeholm wrote: > I was going to add some content to > https://wiki.php.net/rfc/weakreferencesnow but the wiki tells me that > the page is read only for me. I couldn't find > any details on who to contact to change this. > > ~Hannes > Hannes, now you shou

Re: [PHP-DEV] weak references

2011-07-17 Thread Lars Schultz
I too would welcome a solution to this problem, I've run into it several times already and always had to use a semi-satisfactory solution. I hadn't heard about weak-references before, and I generally like the concept. What I am not so sure is wether this makes everything alot more complicated f

Re: [PHP-DEV] weak references

2011-07-17 Thread Ferenc Kovacs
On Sun, Jul 17, 2011 at 3:04 PM, Lars Schultz wrote: > I too would welcome a solution to this problem, I've run into it several > times already and always had to use a semi-satisfactory solution. I hadn't > heard about weak-references before, and I generally like the concept. What I > am not so su

Re: [PHP-DEV] weak references

2011-07-17 Thread Hannes Landeholm
On 17 July 2011 12:38, Ferenc Kovacs wrote: > > Hannes, now you should have karma for the rfc namespace, so you can > now extend the article with your suggestions. Great, I'll start contributing ASAP. What's the next step after the RFC is complete? Testing? Voting? On 17 July 2011 15:04, Lar

Re: [PHP-DEV] weak references

2011-07-17 Thread Pierre Joye
hi, On Sun, Jul 17, 2011 at 5:40 PM, Hannes Landeholm wrote: > On 17 July 2011 12:38, Ferenc Kovacs wrote: >> >>  Hannes, now you should have karma for the rfc namespace, so you can >> now extend the article with your suggestions. > > > > Great, I'll start contributing ASAP. What's the next ste

Re: [PHP-DEV] weak references

2011-07-17 Thread Lars Schultz
Am 16.07.2011 13:23, schrieb Ferenc Kovacs: > we have debug_zval_dump but it is hard to use correctly Well, it's not a simple problem then is it? It wouldn't be too hard if you understood the source of the problem... > with weak references, you wouldn't need to worry about keeping a count > of

Re: [PHP-DEV] weak references

2011-07-17 Thread Lars Schultz
Am 17.07.2011 17:40, schrieb Hannes Landeholm: If you are writing code that caches objects/relations and that caching has a significant impact on memory usage, you need to care about memory allocation/management per definition. Right. That's what I am talking about...a callback on high-memory co

Re: [PHP-DEV] weak references

2011-07-18 Thread Hannes Landeholm
Lars: Please don't break up my sentences and take them out of context before you reply to them. (Hint: If a sentence begins with "so" it's not a good idea to just reply to that sentence.) If you are caching stuff you would rather want to use a strong reference since the objects should be retained

Re: [PHP-DEV] weak references

2011-07-18 Thread Lars Schultz
Am 18.07.2011 09:33, schrieb Hannes Landeholm: Lars: Please don't break up my sentences and take them out of context before you reply to them. (Hint: If a sentence begins with "so" it's not a good idea to just reply to that sentence.) Sorry for misquoting you. I intended to make it clear to which

Re: [PHP-DEV] weak references

2011-07-18 Thread Ferenc Kovacs
>> I hope this will be more clear once the RFC is complete. I will then start >> a >> separate thread for official discussion. > > All I wanted was to point out that introducing such a thing might overly > complicate things for users not familiar with the concept...as the java guy > pointed out in

Re: [PHP-DEV] weak references

2011-07-18 Thread Lars Schultz
Am 18.07.2011 10:15, schrieb Ferenc Kovacs: I think that having to know and care about refcounts and zvals are more complicated than having an Spl class, which can hold a reference for a variable what can be destroyed to free memory. and there is a chance that people are familiar with the Weak re

Re: [PHP-DEV] weak references

2011-07-18 Thread Lars Strojny
While I like SplWeekRef and the somewhat proposed SplWeekRefList, you’ll find attached a patch that exposes a simple function „refcount“ having this signature: int refcount(mixed value) So if you would like to play around with it, have fun. It would be interesting to see if there are any other us

[PHP-DEV] Weak references - object destruction callback?

2009-08-02 Thread Oskar Eisemuth
Hi I try to write a a weak reference extension for php5.3 to break circular object structures, so far I have a test implementation that seems to work fine with my first tests. My current system uses a new base class that returns a new resource via a getWeakRef method. This resource can be