Re: RFC WeakRefs
| From: | Rowan Collins | Date: | Fri, 18 May 2018 12:37:09 +0000 |
| Subject: | Re: RFC WeakRefs | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-102120@lists.php.net to get a copy of this message | ||
On 18 May 2018 13:15:21 BST, Etienne Kneuss <colder@php.net> wrote:
>On Fri, May 18, 2018 at 1:59 PM Rowan Collins <rowan.collins@gmail.com>
>wrote:
>
>> On 17 May 2018 10:35:11 BST, Etienne Kneuss <colder@php.net> wrote:
>> >That said, if the plan is to subsume pecl-weakref, I suggest we also
>> >reimplement weakmaps, which offer a convenient way of storing
>> >meta/cache
>> >data and is not implementable in userland without trade-offs.
>>
>> It looks to me like WeakMap would be fairly trivial to implement in
>> userland as a combination of WeakRef, ArrayAccess, Iterable, and an
>> internal SplObjectStorage for the ability to use objects as keys
>(although
>> I'm not clear why it uses object keys in the first place).
>>
>
>In weakmaps it is the keys that are weak, hence objects only; the
>values
>are arbitrary data associated with them.
>The goal is to provide a way to associate metadata that may also be
>collected in case the key gets collected.
>In some sense it would behave as if this metadata was stored as a
>property
>of the object, only it is stored externally in a weakmap.
Ah, that makes more sense; there didn't seem to be any accrual description in the manual of
what they were for; maybe I was looking in the wrong place. In that case, I understand your request
to include it, and apologise for the noise :)
Regards,
--
Rowan Collins
[IMSoP]