rfc:constdereference

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:constdereference [2011/11/30 06:17] laruencerfc:constdereference [2014/07/07 15:41] – Closed vote ajf
Line 3: Line 3:
   * Date: 2011-11-30   * Date: 2011-11-30
   * Author: Xinchen Hui <laruence@php.net>   * Author: Xinchen Hui <laruence@php.net>
-  * Status: Discuss+  * Status: Implemented in PHP 5.5
   * First Published at: https://wiki.php.net/rfc/constdereference   * First Published at: https://wiki.php.net/rfc/constdereference
  
 ===== Introduction ===== ===== Introduction =====
-small change to make things consistent.+ 
 +little improvement to make things consistent. 
  
 ===== Proposal ===== ===== Proposal =====
-base on feature request: https://bugs.php.net/bug.php?id=60408 , I wrote a patch to make php support const array/string dereference+Base on feature request: https://bugs.php.net/bug.php?id=60408
  
-after patched, following script:+<code> 
 +Please add array constructor dereferencing support 
 + 
 +like JavaScriptC# and all languages excluding PHP 5.4 
 + 
 +<?php 
 + 
 + $i=0; 
 + print(array('pa','th')[$i++]); // pa 
 + print(['wa','ss'][$i++]); // ss 
 + 
 +?> 
 +</code> 
 + 
 +I wrote a patch to make php support const array/string dereferencing. After the patch, the following script works:
 <code php> <code php>
 echo array(1, 2, 3)[0]; //output 1 echo array(1, 2, 3)[0]; //output 1
 echo "foobar"[2]; //output o echo "foobar"[2]; //output o
 echo "foobar"["foo"][0] // output f echo "foobar"["foo"][0] // output f
-</code> 
  
-works.+echo [1,3,4][2]; //output 4 
 +</code> 
 +===== Vote ===== 
 +<doodle  
 +title="do you think it is okey to apply this to TRUNK(not 5.4)?" auth="laruence" voteType="single" closed="true"> 
 +   * yes 
 +   * no 
 +</doodle>
  
 ===== Patches ===== ===== Patches =====
-   http://www.laruence.com/php-dev/php-5.4-trunk-req60408.patch+   https://gist.github.com/2375008
 ===== Tests ===== ===== Tests =====
    * http://www.laruence.com/php-dev/const_dereference_001.phpt    * http://www.laruence.com/php-dev/const_dereference_001.phpt
    * http://www.laruence.com/php-dev/const_dereference_002.phpt    * http://www.laruence.com/php-dev/const_dereference_002.phpt
 +   * http://www.laruence.com/php-dev/const_dereference_003.phpt
  
 ===== Changelog ===== ===== Changelog =====
   * 2011-11-30 Xinchen Hui: Initial RFC creation   * 2011-11-30 Xinchen Hui: Initial RFC creation
 +  * 2011-12-13 Xinchen Hui: Start voting
 +  * 2012-04-13 Xinchen Hui: Update patch, fixed issue spot by Dmitry
 +  * 2012-04-13 Xinchen Hui: Close voting
 +  * 2012-04-17 Xinchen Hui: Committed && Close
rfc/constdereference.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1