rfc:normalize-array-auto-increment-on-copy-on-write

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
Last revisionBoth sides next revision
rfc:normalize-array-auto-increment-on-copy-on-write [2019/06/19 23:11] wesnetmorfc:normalize-array-auto-increment-on-copy-on-write [2019/06/28 21:07] wesnetmo
Line 1: Line 1:
-====== PHP RFC: Normalize array'"auto-increment" value on copy on write ======+====== PHP RFC: Normalize arrays' "auto-increment" value on copy on write ======
  
   * Version: 0.1   * Version: 0.1
   * Date: 2019-06-19   * Date: 2019-06-19
   * Author: Wes (@WesNetmo)   * Author: Wes (@WesNetmo)
-  * Status: Under Discussion+  * Status: Voting
   * First Published at: http://wiki.php.net/rfc/normalize-array-auto-increment-on-copy-on-write   * First Published at: http://wiki.php.net/rfc/normalize-array-auto-increment-on-copy-on-write
  
Line 18: Line 18:
 </PHP> </PHP>
  
-This is currently not guaranteed, and because of ''array''s' multiple nature, it is not+This is currently not guaranteed, and because of ''array''s' all-doing nature, it is not
 possible to always enforce this property -- but it should be in some dangerous cases, possible to always enforce this property -- but it should be in some dangerous cases,
 namely when functions from (potential) different authors are interacting. namely when functions from (potential) different authors are interacting.
Line 44: Line 44:
 </PHP> </PHP>
  
-This behavior happens, unfortunately, also between different scopes. Our functions can + 
-receive "broken" ''array''-lists from third-parties that only appear to be well-indexed, +This happens also between different function scopes. Our functions can receive "broken" 
-but that in reality are not, because they were misused during their lifetime (for example, +''array''-lists from third-parties that only appear to be well-indexed, but that in 
-it was used ''unset()'' on them, instead of ''array_pop()'').+reality are not, because they were misused during their lifetime (classic example, it was 
 +used ''unset($array[$lastIndex])'' on them, instead of ''array_pop($array)'').
  
 As result of that, despite "copy on write", the value-type semantics, and even a different As result of that, despite "copy on write", the value-type semantics, and even a different
Line 97: Line 98:
 be considered a bug-fix, rather than a behavior change; it offers protection against be considered a bug-fix, rather than a behavior change; it offers protection against
 ''array''-lists that were misused with ''unset()'' instead of ''array_pop/_splice/_shift'' ''array''-lists that were misused with ''unset()'' instead of ''array_pop/_splice/_shift''
-and thus will only affect code that should be improved already. Furthermore, the +and thus will only affect code that is already a candidate for improvements. Furthermore, 
-"auto-increment" value is copied inconsistently already, when the ''array'' is empty:+the "auto-increment" value is copied inconsistently, when the ''array'' is empty:
  
 <PHP> <PHP>
Line 113: Line 114:
 // $b is [0 => 2], rather than [2 => 2] // $b is [0 => 2], rather than [2 => 2]
 </PHP> </PHP>
 +
 +The proposed change would make the behavior consistent and safer.
  
 ===== Proposed PHP Version(s) ===== ===== Proposed PHP Version(s) =====
Line 122: Line 125:
 Vote will require 2/3 majority Vote will require 2/3 majority
  
 +<doodle title="Normalize the auto-increment value on array copy?" auth="wesnetmo" voteType="single" closed="false">
 +   * Yes
 +   * No
 +</doodle>
 +
 +===== References  =====
 +
 +  * [[https://externals.io/message/105992|Pre-vote discussion on externals.io]]
rfc/normalize-array-auto-increment-on-copy-on-write.txt · Last modified: 2019/06/28 21:13 by wesnetmo