rfc:weak_maps

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
rfc:weak_maps [2019/11/04 21:04] – Explan difference nikicrfc:weak_maps [2020/01/03 09:56] (current) – Implemented nikic
Line 3: Line 3:
   * Author: Nikita Popov <nikic@php.net>   * Author: Nikita Popov <nikic@php.net>
   * Proposed Version: PHP 8.0   * Proposed Version: PHP 8.0
-  * Status: Under Discussion+  * Status: Implemented
   * Implementation: https://github.com/php/php-src/pull/4882   * Implementation: https://github.com/php/php-src/pull/4882
  
Line 83: Line 83:
 ===== Vote ===== ===== Vote =====
  
-Add WeakMap class in PHP 8.0? Yes/No.+Voting started 2019-12-18 and closes 2020-01-01. 
 + 
 +<doodle title="Add WeakMap class in PHP 8.0?" auth="nikic" voteType="single" closed="true"> 
 +   Yes 
 +   No 
 +</doodle>
  
 ===== Differences to spl_object_id() and WeakReference ===== ===== Differences to spl_object_id() and WeakReference =====
Line 95: Line 100:
   * The value stored under the ID will not be released when the object is destroyed.   * The value stored under the ID will not be released when the object is destroyed.
  
-Using the ''WeakReference'' class introduced in PHP 7.4, it is possible to avoid the first two objectsbut using the following construction:+Using the ''WeakReference'' class introduced in PHP 7.4, it is possible to avoid the first two issuesby using the following construction:
  
 <PHP> <PHP>
Line 114: Line 119:
 </PHP> </PHP>
  
-This makes use of the ''WeakReference'' to determine whether the object ID has been reused. However, this does not solve the third problem: The data will not be released when the object is destroyed. It will only be released on the next access, or if a garbage collection mechanism for the map is implement, which performs regular sweeps of the whole map.+This makes use of the ''WeakReference'' to determine whether the object ID has been reused. However, this does not solve the third problem: The data will not be released when the object is destroyed. It will only be released on the next access with an object that has the same reused ID, or if a garbage collection mechanism, which performs regular sweeps of the whole map, is implemented. 
 + 
 +A native weak map implementation will instead remove the value from the weak map as soon as the object key is destroyed.
rfc/weak_maps.1572901496.txt.gz · Last modified: 2019/11/04 21:04 by nikic