rfc:generator-delegation

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:generator-delegation [2015/03/09 18:42]
rdlowrey rewording
rfc:generator-delegation [2015/03/30 04:34]
rdlowrey Close vote
Line 4: Line 4:
   * Author: Daniel Lowrey <rdlowrey@php.net>   * Author: Daniel Lowrey <rdlowrey@php.net>
   * Contributors: Bob Weinand <bwoebi@php.net>   * Contributors: Bob Weinand <bwoebi@php.net>
-  * Status: Under Discussion+  * Status: Accepted
   * First Published at: http://wiki.php.net/rfc/generator-delegation   * First Published at: http://wiki.php.net/rfc/generator-delegation
  
Line 75: Line 75:
                 $send = false;                 $send = false;
             } else {             } else {
-                $throw $e;+                throw $e;
             }             }
         }         }
Line 333: Line 333:
 while($shared->valid()) { $shared->next(); } while($shared->valid()) { $shared->next(); }
 $delegator = delegator($shared); $delegator = delegator($shared);
-while($delegator->valid()) { $delegator->next(); } + 
-var_dump($delegator->getReturn()); /int(42)+foreach ($delegator as $value) { 
 +    var_dump($value); 
 +
 +var_dump($delegator->getReturn()); 
 + 
 +/
 +int(42) 
 +// This is our only output because no values are yielded 
 +// from the already-completed shared subgenerator 
 +*/
 </code> </code>
  
Line 374: Line 383:
 ==== Error States ==== ==== Error States ====
  
-There are two scenarios in which ''yield from'' usage can result in a fatal error or uncaught exception:+There are two scenarios in which ''yield from'' usage can result in an ''EngineException'':
  
   * Using ''yield from <expr>'' where <expr> evaluates to a generator which previously terminated with an uncaught exception results in an ''EngineException''.   * Using ''yield from <expr>'' where <expr> evaluates to a generator which previously terminated with an uncaught exception results in an ''EngineException''.
Line 382: Line 391:
 ===== Rejected Ideas ===== ===== Rejected Ideas =====
  
-The original version of this RFC proposed a ''yield *'' syntax. This was rejected in favor of +The original version of this RFC proposed a ''yield *'' syntax. The ''yield *'' syntax was rejected in favor of 
-''yield from'' on the basis that it would break backwards compatibility. Additionally, the ''yield *'' +''yield from'' on the basis that ''*'' would break backwards compatibility. Additionally, the ''yield *'' 
-form was considered less readable option that the current proposal.+form was considered less readable than the current proposal.
  
  
Line 406: Line 415:
 **Python** **Python**
  
-Python 3.3 generators support ''yield from'':+Python 3.3 generators support the ''yield from'' syntax:
  
 <code python> <code python>
Line 439: Line 448:
 **JavaScript** **JavaScript**
  
-Javascript ES6 generators support the ''yield from'' syntax:+Javascript ES6 generators support the ''yield*'' syntax:
  
 <code javascript> <code javascript>
Line 477: Line 486:
  
  
-===== Proposed Voting Choices ===== +===== Vote =====
- +
-Two voting choices are proposed†:+
  
-  * **YES**, implement the ''yield from'' syntax allowing generator delegation in PHP 7*+A 2/3 "Yes" vote is required to implement this proposal. Voting will continue through March 29, 2015.
  
-  * **NO**, do not modify existing Generator behavior+<doodle title="Allow Generator delegation in PHP7" auth="rdlowrey" voteType="single" closed="true"> 
 +   * Yes 
 +   No 
 +</doodle>
  
-A 2/3 "Yes" vote is required to implement this proposal.+.
  
-†: The success of this vote depends on the success of the accompanying [[rfc:generator-return-expressions|Generator Return Expressions]] RFC. +The success of this vote depends on the success of the accompanying [[rfc:generator-return-expressions|Generator Return Expressions]] RFC. Should Generator Return Expressions be rejected the voting outcome of this RFC will be rendered moot.
-Should Generator Return Expressions be rejected the voting outcome of this RFC will be rendered moot.+
  
 ===== Patches and Tests ===== ===== Patches and Tests =====
  
-The current patch is approaching "final" status and can be found here:+The current patch is considered "final" and can be found here:
  
 https://github.com/bwoebi/php-src/commits/coroutineDelegation https://github.com/bwoebi/php-src/commits/coroutineDelegation
rfc/generator-delegation.txt · Last modified: 2017/09/22 13:28 (external edit)