rfc:trailing-comma-function-args

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:trailing-comma-function-args [2013/02/20 11:19] – [The patch] Add patch for declarations as well pollitarfc:trailing-comma-function-args [2017/09/22 13:28] (current) – external edit 127.0.0.1
Line 1: Line 1:
-====== Request for Comments: How to write RFCs ======+====== Request for Comments: Trailing comma function args ======
   * Version: 1.0   * Version: 1.0
   * Date: 2013-02-19   * Date: 2013-02-19
   * Author: Sara Golemon <pollita@php.net>   * Author: Sara Golemon <pollita@php.net>
-  * Status: Under Discussion+  * Status: Rejected
   * First Published at: http://wiki.php.net/rfc/trailing-comma-function-args   * First Published at: http://wiki.php.net/rfc/trailing-comma-function-args
  
Line 30: Line 30:
 Which means that adding additional parameters to the call forces touching both the new line and the prior one, which is bad for VCS history. Which means that adding additional parameters to the call forces touching both the new line and the prior one, which is bad for VCS history.
  
-This RFC proposes to allow trailing commas in function and method call argument lists.+Similarly, function declarations have the same inconsistency with array() and list().
  
-===== The patch =====+  <?php 
 +  // Invalid currently 
 +  function foo( 
 +             $bar, 
 +             ) { 
 +    /* ... */ 
 +  }
  
-Could not be much simpler...+This RFC proposes to allow trailing commas in function and method call argument lists and function argument declarations.
  
-  diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y +====The patch =====
-  index ccbc9b1..6b6de2e 100644 +
-  --- a/Zend/zend_language_parser.y +
-  +++ b/Zend/zend_language_parser.y +
-  @@ -542,7 +542,7 @@ optional_class_type: +
-   +
-   function_call_parameter_list: +
-                  '(' ')' { Z_LVAL($$.u.constant) 0; } +
-  -             '(' non_empty_function_call_parameter_list ')'  { $$ $2; } +
-  +             '(' non_empty_function_call_parameter_list possible_comma ')'   { $$ $2; } +
-          |       '(' yield_expr ')'      { Z_LVAL($$.u.constant) 1; zend_do_pass_param(&$2, ZEND_SEND_VAL, Z_LVAL($$.u.constant) TSRMLS_CC); } +
-   ; +
-  +
-The following additional patch provides for trailing commas in declarations as well. (e.g. function foo($arg, ) { ... } )+
  
-  diff --git a/Zend/zend_language_parser.y b/Zend/zend_language_parser.y +https://github.com/sgolemon/php-src/compare/master...trailing-comma
-  index ccbc9b1..cf6679f 100644 +
-  --- a/Zend/zend_language_parser.+
-  +++ b/Zend/zend_language_parser.+
-  @@ -515,7 +515,7 @@ new_else_single:   +
-    +
-    +
-   parameter_list: +
-  -               non_empty_parameter_list +
-  +               non_empty_parameter_list possible_comma +
-          |       /* empty */ +
-   ; +
-   +
  
 +HipHop version: https://github.com/facebook/hiphop-php/commit/c1b7da6a4c128af5ddfc75f515c205de9f417a1e
 ===== What's left out on purpose ===== ===== What's left out on purpose =====
  
Line 87: Line 69:
   }   }
  
-===== Tests =====+===== Vote ===== 
 + 
 +Note: Consideration for 5.6 inclusion, not 5.5. 
 + 
 +<doodle  
 +title="Should the current optional trailing comma implementation be merged" auth="pollita" voteType="single" closed="True"> 
 +   * Yes 
 +   * No 
 +</doodle>
  
-Yes, I'll write some.+===== Changelog =====
  
 +  * Expanded proposal to include declarations as well as arguments 2013-02-20 11:23 GMT
rfc/trailing-comma-function-args.1361359172.txt.gz · Last modified: 2017/09/22 13:28 (external edit)