On 17 May 2018 10:35:11 BST, Etienne Kneuss <col...@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).

The only part that seems hard to write efficiently is Countable support, since 
you'd have to iterate the internal hash checking for unset objects. I suppose 
iteration would also slow down a bit of lots of the references were now unset. 
Is that the trade-off you're referring to, that the C implementation has some 
magic to avoid?

Regards,

-- 
Rowan Collins
[IMSoP]

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

Reply via email to