Skip to content

Commit 7cc4490

Browse files
authored
Add do * syntax as an alternative
1 parent e656e79 commit 7cc4490

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,14 @@ foo: {
184184

185185
## `return` Statements
186186

187-
It's unclear what the `return` statement should do inside these generators. It could either return out of the outer function or abruptly stop the iteration of the generator. I'm leaning to just forbidding `return` for now.
187+
It's unclear what the `return` statement should do inside these generators. It could either return out of the outer function or abruptly stop the iteration of the generator. I'm leaning to just forbidding `return` for now. Early returns are awkward but works, which seems fine because the use case for the completion value is rare anyway.
188188

189189
`throw` works just fine though.
190190

191+
## `do * { ... }` Syntax Alternative
192+
193+
An alternative syntax could use the `do` prefix since it is effectively in the same category as `do` expressions and this might help explain it once you are familiar with `do`-expressions. I tend to prefer the shortest possible syntax when possible though.
194+
191195
## Related Proposals
192196

193197
[`do` expressions](https://github.com/tc39/proposal-do-expressions)

0 commit comments

Comments
 (0)