rfc:generator-delegation
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
rfc:generator-delegation [2015/03/09 16:37] – upate other language examples rdlowrey | rfc:generator-delegation [2015/04/18 16:49] – Status Implemented bwoebi | ||
---|---|---|---|
Line 4: | Line 4: | ||
* Author: Daniel Lowrey < | * Author: Daniel Lowrey < | ||
* Contributors: | * Contributors: | ||
- | * Status: | + | * Status: |
* First Published at: http:// | * First Published at: http:// | ||
====== Abstract ====== | ====== Abstract ====== | ||
- | This RFC proposes new '' | + | This RFC proposes new '' |
====== Proposal ====== | ====== Proposal ====== | ||
Line 75: | Line 75: | ||
$send = false; | $send = false; | ||
} else { | } else { | ||
- | | + | throw $e; |
} | } | ||
} | } | ||
Line 146: | Line 146: | ||
The other reason return values are required stems from the previously discussed refactoring principle. | The other reason return values are required stems from the previously discussed refactoring principle. | ||
Specifically: | Specifically: | ||
- | like ordinary functions | + | like ordinary functions. |
Using the proposed syntax an ordinary function '' | Using the proposed syntax an ordinary function '' | ||
Line 164: | Line 164: | ||
simply by thinking of '' | simply by thinking of '' | ||
- | **NB:** The actual implementation of single-threaded concurrency | + | **NB:** The actual implementation of coroutine task schedulers is outside the scope of |
this document. This RFC focuses only on the language-level machinery needed to make such tools more | this document. This RFC focuses only on the language-level machinery needed to make such tools more | ||
feasible in userland. It should be obvious that simply moving code into a generator function will | feasible in userland. It should be obvious that simply moving code into a generator function will | ||
- | not instantly | + | not somehow |
Line 333: | Line 333: | ||
while($shared-> | while($shared-> | ||
$delegator = delegator($shared); | $delegator = delegator($shared); | ||
- | while($delegator-> | + | |
- | var_dump($delegator-> | + | foreach |
+ | var_dump($value); | ||
+ | } | ||
+ | var_dump($delegator-> | ||
+ | |||
+ | /* | ||
+ | int(42) | ||
+ | // This is our only output because no values are yielded | ||
+ | // from the already-completed shared subgenerator | ||
+ | */ | ||
</ | </ | ||
Line 374: | Line 383: | ||
==== Error States ==== | ==== Error States ==== | ||
- | There are two scenarios in which '' | + | There are two scenarios in which '' |
* Using '' | * Using '' | ||
Line 382: | Line 391: | ||
===== Rejected Ideas ===== | ===== Rejected Ideas ===== | ||
- | The original version of this RFC proposed a '' | + | The original version of this RFC proposed a '' |
- | '' | + | '' |
- | form was considered | + | form was considered less readable |
Line 406: | Line 415: | ||
**Python** | **Python** | ||
- | Python 3.3 generators support '' | + | Python 3.3 generators support |
<code python> | <code python> | ||
Line 439: | Line 448: | ||
**JavaScript** | **JavaScript** | ||
- | Javascript ES6 generators support the '' | + | Javascript ES6 generators support the '' |
<code javascript> | <code javascript> | ||
Line 477: | Line 486: | ||
- | ===== Proposed Voting Choices | + | ===== Vote ===== |
- | + | ||
- | Two voting choices are proposed†: | + | |
- | * **YES**, | + | A 2/3 " |
- | * **NO**, do not modify existing Generator behavior | + | <doodle title=" |
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
- | A 2/3 " | + | . |
- | †: The success of this vote depends on the success of the accompanying [[rfc: | + | The success of this vote depends on the success of the accompanying [[rfc: |
- | 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 | + | The current patch is considered |
https:// | https:// |
rfc/generator-delegation.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1