Re: [VOTE] Weak References

From: Date: Wed, 07 Sep 2011 00:26:46 +0000
Subject: Re: [VOTE] Weak References
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  Groups: php.internals 
Request: Send a blank email to [email protected] to get a copy of this message
Hi,

On Sat, Sep 3, 2011 at 19:21, Nicolas Grekas
<[email protected]>wrote:

> >
> > $pseudoWeakMap = array();
> > $pseudoWeakMap[spl_object_**hash($obj)] = new WeakReference($obj);
> >
> > or did I misunderstand the concept? I hope I'll have a chance to use
> > WeakReferences soon in my project;)
>
>
>
> I also believe that this is the logic, but from the doc, when an object is
> destroyed, its hash may be reused for other objects.
> So this implementation could possibly have bad side effect, isn't it ?
>
> Nicolas
>

I don't understand how the code you just gave would be useful in practice?


I've implemented a WeakMap class in the weakref pecl ext, see:

http://svn.php.net/viewvc/pecl/weakref/trunk/tests/weakmap_001.phpt?revision=316293&view=markup

for an example of usage.

I believe this better fit people's needs. Or did you have something else in
mind?

Best,

-- 
Etienne Kneuss
http://www.colder.ch


Thread (69 messages)

« previous php.internals (#55265) next »