Skip to content

Commit e10c2a6

Browse files
committed
Unresolved questions and future ideas
1 parent c905ce0 commit e10c2a6

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

text/0000-gen-fn.md

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,23 +214,43 @@ def odd_dup(values):
214214
- What parts of the design do you expect to resolve through the implementation of this feature before stabilization?
215215
- What related issues do you consider out of scope for this RFC that could be addressed in the future independently of the solution that comes out of this RFC?
216216

217+
## Panicking
218+
219+
What happens when a `gen` block that panicked gets `next` called again? Do we need to poison the iterator?
220+
221+
## Fusing
222+
223+
Are `gen` blocks fused? Or may they behave eratically after returning `None` the first time?
224+
217225
# Future possibilities
218226
[future-possibilities]: #future-possibilities
219227

220-
Think about what the natural extension and evolution of your proposal would
221-
be and how it would affect the language and project as a whole in a holistic
222-
way. Try to use this section as a tool to more fully consider all possible
223-
interactions with the project and language in your proposal.
224-
Also consider how this all fits into the roadmap for the project
225-
and of the relevant sub-team.
228+
## `yield from` (forwarding operation)
229+
230+
Python has the ability to `yield from` an iterator.
231+
Effectively this is syntax sugar for looping over all elements of the iterator and yielding them individually.
232+
There are infinite options to choose from if we want such a feature, so I'm just going to list the general ideas below:
226233

227-
This is also a good place to "dump ideas", if they are out of scope for the
228-
RFC you are writing but otherwise related.
234+
### Do nothing, just use loops
235+
236+
```rust
237+
for x in iter {
238+
yield x
239+
}
240+
```
229241

230-
If you have tried and cannot think of any future possibilities,
231-
you may simply state that you cannot think of anything.
242+
### language support
232243

233-
Note that having something written down in the future-possibilities section
234-
is not a reason to accept the current or a future RFC; such notes should be
235-
in the section on motivation or rationale in this or subsequent RFCs.
236-
The section merely provides additional information.
244+
we could do something like postfix `yield` or an entirely new keyword, or...
245+
246+
```rust
247+
iter.yield
248+
```
249+
250+
### stlib macro
251+
252+
We could add a macro to the standard library and prelude, the macro would just expand to the for loop + yield.
253+
254+
```rust
255+
yield_all!(iter)
256+
```

0 commit comments

Comments
 (0)