rfc:language-constructs-syntax-changes
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
rfc:language-constructs-syntax-changes [2020/07/04 07:25] – created brzuchal | rfc:language-constructs-syntax-changes [2020/07/22 08:36] (current) – withdrawning brzuchal | ||
---|---|---|---|
Line 3: | Line 3: | ||
* Date: 2020-07-04 | * Date: 2020-07-04 | ||
* Author: Michał Marcin Brzuchalski, | * Author: Michał Marcin Brzuchalski, | ||
- | * Status: | + | * Status: |
* Target Version: PHP 8.0 | * Target Version: PHP 8.0 | ||
* First Published at: http:// | * First Published at: http:// | ||
- | Language constructs syntax | + | Language constructs syntax changes |
===== Introduction ===== | ===== Introduction ===== | ||
In 25yrs history, many language constructs were allowed in different forms depending on the context. | In 25yrs history, many language constructs were allowed in different forms depending on the context. | ||
- | Some language constructs like '' | + | A '' |
- | nor in write context require parentheses while some language constructs like '' | + | nor in write context |
but they don't require parentheses no matter of context. | but they don't require parentheses no matter of context. | ||
- | Another language constructs like '' | + | The same goes to '' |
- | parentheses if no argument is passed | + | be used as a function |
- | There' | ||
- | INI directive '' | ||
- | giving false-positive results. | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | The proposal is to bring more sanity into the language by adding/relaxing restrictions in some language constructs. | + | The proposal is to bring more sanity into the language by relaxing restrictions in some language constructs. |
==== Allow skip of parentheses for declare ==== | ==== Allow skip of parentheses for declare ==== | ||
- | A '' | + | A '' |
+ | Therefore | ||
<code php> | <code php> | ||
declare strict_types = 1; | declare strict_types = 1; | ||
Line 42: | Line 40: | ||
==== Allow to skip parentheses for compiler halt ==== | ==== Allow to skip parentheses for compiler halt ==== | ||
- | Some language | + | A language |
- | to stop parsing. It is the one also which looks like a function and therefore | + | This language construct stops parsing. |
- | parentheses but it can never be used as a function in write context cause it's considered a syntax error. | + | It looks like a function and it always |
+ | cause it's considered a syntax error. | ||
<code php> | <code php> | ||
- | __halt_compiler(); | + | $foo = __halt_compiler(); |
</ | </ | ||
Line 54: | Line 53: | ||
__halt_compiler; | __halt_compiler; | ||
</ | </ | ||
- | |||
- | ==== Require parentheses in constructs allowed to be used like a function ==== | ||
- | A '' | ||
- | Therefore when used in a write context it still doesn' | ||
- | |||
- | Some language constructs like '' | ||
- | The difference in both is that '' | ||
- | no issue there. The thing is that '' | ||
- | |||
- | The proposal is to require use of parentheses for '' | ||
- | <code php> | ||
- | false or print(" | ||
- | </ | ||
- | |||
- | ==== Forbid use of language constructs in write context which never return ==== | ||
- | Some language constructs like '' | ||
- | The fact that they allow skipping parentheses if no value is passed makes no sense in write context because of the fact they never return a value. | ||
- | |||
- | Therefore the proposal is to consider use of '' | ||
- | when used like in example: | ||
- | <code php> | ||
- | $foo = exit; // should be parse error | ||
- | $foo = die; // same here | ||
- | </ | ||
- | |||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
- | These will no longer be considered valid syntax: | + | None. |
- | <code php> | + | |
- | $foo = exit; | + | |
- | $foo = die; | + | |
- | false or print " | + | |
- | </ | + | |
- | + | ||
- | This will be considered a valid syntax: | + | |
- | <code php> | + | |
- | __compiler_halt; | + | |
- | </ | + | |
===== Proposed PHP Version(s) ===== | ===== Proposed PHP Version(s) ===== | ||
Line 108: | Line 72: | ||
==== New Constants ==== | ==== New Constants ==== | ||
None. | None. | ||
- | |||
- | ===== Future Scope ===== | ||
- | Deprecate non-function like language constructs to be allowed with parentheses in future. | ||
===== Proposed Voting Choices ===== | ===== Proposed Voting Choices ===== | ||
This is a language change and requires 2/3 majority in 4 separate pools with simple Yes/No options. | This is a language change and requires 2/3 majority in 4 separate pools with simple Yes/No options. | ||
- | |||
- | ===== Patches and Tests ===== | ||
- | TBD. | ||
===== Implementation ===== | ===== Implementation ===== | ||
- | TBD. | + | * [[https:// |
+ | * [[https:// |
rfc/language-constructs-syntax-changes.1593847547.txt.gz · Last modified: 2020/07/04 07:25 by brzuchal