rfc:ast_based_parsing_compilation_process

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
rfc:ast_based_parsing_compilation_process [2012/09/07 14:01]
nikic
rfc:ast_based_parsing_compilation_process [2013/08/24 19:13]
nikic add ML discussion
Line 3: Line 3:
   * Author: Nikita Popov <​nikic@php.net>​   * Author: Nikita Popov <​nikic@php.net>​
   * Status: Under Discussion   * Status: Under Discussion
 +  * [[http://​markmail.org/​message/​trt5oz5uioxe3fdv|Mailing list discussion]]
  
 ===== Introduction ===== ===== Introduction =====
Line 42: Line 43:
 With the current single-pass compiler some things are very hard / near impossible to implement. This actively influences syntax decisions. With the current single-pass compiler some things are very hard / near impossible to implement. This actively influences syntax decisions.
  
-Two examples of syntax that is currently not possible, but would be possible with a syntax tree:+A few examples of syntax that is currently not possible, but would be possible with a syntax tree:
  
   * Array destructuring using something like ''​[$a,​ $b, $c] = $array''​ instead of a dedicated ''​list()''​ syntax. This is common in other languages, but not possible in PHP.   * Array destructuring using something like ''​[$a,​ $b, $c] = $array''​ instead of a dedicated ''​list()''​ syntax. This is common in other languages, but not possible in PHP.
   * List comprehensions / generator expressions where the result expression comes first, e.g. ''​[x * x for x in list]''​ in Python. In PHP only the reverse syntax is possible: ''​[foreach ($list as $x) yield $x * $x]''​   * List comprehensions / generator expressions where the result expression comes first, e.g. ''​[x * x for x in list]''​ in Python. In PHP only the reverse syntax is possible: ''​[foreach ($list as $x) yield $x * $x]''​
 +  * C#-style expression trees (which form the basis for LINQ)
  
 Apart from larger syntax limitations the current system commonly also affects smaller syntax decisions. One example here are the strange parentheses requirements for the ''​yield''​ expression. Those requirements exist solely for technical reasons and would not be required with an AST-generating parser. Apart from larger syntax limitations the current system commonly also affects smaller syntax decisions. One example here are the strange parentheses requirements for the ''​yield''​ expression. Those requirements exist solely for technical reasons and would not be required with an AST-generating parser.
rfc/ast_based_parsing_compilation_process.txt · Last modified: 2017/09/22 13:28 (external edit)