rfc:const_scalar_exprs

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:const_scalar_exprs [2013/11/03 10:42] – [Introduction] bwoebirfc:const_scalar_exprs [2013/11/28 14:34] – normalize status line nikic
Line 1: Line 1:
 ====== PHP RFC: Constant Scalar Expressions ====== ====== PHP RFC: Constant Scalar Expressions ======
-  * Version: 0.1 
   * Date: 2013-11-03   * Date: 2013-11-03
   * Author: Bob Weinand <bwoebi@php.net>   * Author: Bob Weinand <bwoebi@php.net>
-  * Status: In Draft+  * Status: Implemented in PHP 5.6
   * First Published at: https://wiki.php.net/rfc/const_scalar_exprs   * First Published at: https://wiki.php.net/rfc/const_scalar_exprs
     * This is a follow-up to https://wiki.php.net/rfc/const_scalar_expressions from Anthony Ferrara <ircmaxell@php.net> (which was without constant support)     * This is a follow-up to https://wiki.php.net/rfc/const_scalar_expressions from Anthony Ferrara <ircmaxell@php.net> (which was without constant support)
Line 15: Line 14:
 The main difference to Anthony's RFC is (apart from a few operators more) that constants can be involved in these scalar operations: The main difference to Anthony's RFC is (apart from a few operators more) that constants can be involved in these scalar operations:
  
-<file const_scalar_exprs_diff.php>+<file php const_scalar_exprs_diff.php> 
 +<?php 
 const a = 1; const a = 1;
  
 const b = a?2:100; // here the value of the constant "b" is dependent on the constant "a" const b = a?2:100; // here the value of the constant "b" is dependent on the constant "a"
 +
 +?>
 </file> </file>
 ===== Proposal ===== ===== Proposal =====
Line 38: Line 41:
   * //&// - Bitwise AND   * //&// - Bitwise AND
   * //^// - Bitwise XOR   * //^// - Bitwise XOR
-  * //<<// - Bitwise Shift Left +  * //<nowiki><<</nowiki>// - Bitwise Shift Left 
-  * //>>// - Bitwise Shift Right+  * //<nowiki>>></nowiki>// - Bitwise Shift Right
   * //.// - Concatenation   * //.// - Concatenation
   * //?:// - Ternary Operator   * //?:// - Ternary Operator
Line 68: Line 71:
   * //<nowiki>__FUNCTION__</nowiki>// - Function magic constant   * //<nowiki>__FUNCTION__</nowiki>// - Function magic constant
   * //<nowiki>__NAMESPACE__</nowiki>// - Namespace magic constant   * //<nowiki>__NAMESPACE__</nowiki>// - Namespace magic constant
-  * //<nowiki><<<HEREDOC</nowiki>// - HEREDOC string syntax+  * //<nowiki><<<HEREDOC</nowiki>// - HEREDOC string syntax (without variables) 
 +  * //<nowiki><<<'NOWDOC'</nowiki>// - NOWDOC string syntax
   * //SOME_RANDOM_CONSTANT// - Constants   * //SOME_RANDOM_CONSTANT// - Constants
   * //class_name::SOME_CONST// - Class constants   * //class_name::SOME_CONST// - Class constants
Line 136: Line 140:
     static $a = 1 + 1;     static $a = 1 + 1;
     static $b = [1 << 2];     static $b = [1 << 2];
-    static $c = 0x01 BAR;+    static $c = 0x01 BAR;
 } }
 ?> ?>
Line 152: Line 156:
  
 An implementation based off of current master is available: [[https://github.com/bwoebi/php-src/tree/const_scalar_exprs|Implementation On GitHub]] ([[https://github.com/bwoebi/php-src/compare/const_scalar_exprs|Diff On GitHub]]) An implementation based off of current master is available: [[https://github.com/bwoebi/php-src/tree/const_scalar_exprs|Implementation On GitHub]] ([[https://github.com/bwoebi/php-src/compare/const_scalar_exprs|Diff On GitHub]])
 +
 +The patch is ready to be merged. (Opcache support is included, thanks to Dmitry)
 +
 +===== Note on implementation =====
 +
 +The implementation of the scalar expressions is based on an AST. That AST implementation eventually could be used later as a general-purpose AST for compiler with a few tweaks.
 +
 +===== Vote =====
 +
 +<doodle title="Should the patch for this RFC be merged into PHP 5.6?" auth="bwoebi" voteType="single" closed="true">
 +   * Yes
 +   * No
 +</doodle>
 +
 +The vote started the 20th November 2013 and ended the 27th November 2013.
rfc/const_scalar_exprs.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1