rfc:const_scalar_exprs
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:const_scalar_exprs [2013/11/03 00:20] – created bwoebi | rfc:const_scalar_exprs [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
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 < | * Author: Bob Weinand < | ||
- | * Status: | + | * Status: |
* First Published at: https:// | * First Published at: https:// | ||
* This is a follow-up to https:// | * This is a follow-up to https:// | ||
Line 13: | Line 12: | ||
This can allow for writing far easier to understand code, by allowing for far more expressive code. | This can allow for writing far easier to understand code, by allowing for far more expressive code. | ||
+ | The main difference to Anthony' | ||
+ | |||
+ | <file php const_scalar_exprs_diff.php> | ||
+ | <?php | ||
+ | |||
+ | const a = 1; | ||
+ | |||
+ | const b = a?2:100; // here the value of the constant " | ||
+ | |||
+ | ?> | ||
+ | </ | ||
===== Proposal ===== | ===== Proposal ===== | ||
Line 31: | Line 41: | ||
* //&// - Bitwise AND | * //&// - Bitwise AND | ||
* //^// - Bitwise XOR | * //^// - Bitwise XOR | ||
- | * //<<// | + | * //< |
- | * //>>// | + | * //<nowiki>>></ |
* //.// - Concatenation | * //.// - Concatenation | ||
* //?:// - Ternary Operator | * //?:// - Ternary Operator | ||
Line 38: | Line 48: | ||
* //< | * //< | ||
* //==// - Equal | * //==// - Equal | ||
+ | * //!=// - Not Equal | ||
* //<// - Smaller | * //<// - Smaller | ||
* //>// - Greater | * //>// - Greater | ||
* //===// - Identical | * //===// - Identical | ||
+ | * //!==// - Not Identical | ||
* //&&// | * //&&// | ||
* //||// / //or// - Boolean OR | * //||// / //or// - Boolean OR | ||
Line 59: | Line 71: | ||
* //< | * //< | ||
* //< | * //< | ||
- | * //< | + | * //< |
+ | * //< | ||
* // | * // | ||
* // | * // | ||
Line 127: | 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 143: | Line 156: | ||
An implementation based off of current master is available: [[https:// | An implementation based off of current master is available: [[https:// | ||
+ | |||
+ | 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=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
+ | |||
+ | The vote started the 20th November 2013 and ended the 27th November 2013. |
rfc/const_scalar_exprs.1383438039.txt.gz · Last modified: 2017/09/22 13:28 (external edit)