Skip to content

Commit

Permalink
Merge pull request #1 from Ericson2314/fn-lifetime
Browse files Browse the repository at this point in the history
Add unresolved question of `break 'fn ..`
  • Loading branch information
llogiq authored Jan 7, 2017
2 parents fb45c89 + 4f9b2c1 commit 041dc18
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions text/0000-fn-lifetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,19 @@ What other designs have been considered? What is the impact of not doing this?
# Unresolved questions
[unresolved]: #unresolved-questions

- Should we allow `break 'fn ..` with the same semantics as `return ..`. In
[RFC 1624](https:/rust-lang/rfcs/blob/master/text/1624-loop-break-value.md)
we got breaking with a value out of loops, so the value part is already
established. This provides one canonnical syntax for breaking out of a loops
or functions, leaving `return` just a convenience. In a future with full
lifetime ascription, this would further generalize to supporting all labeled
blocks, not just loops and functions.

A downside is `continue 'a` will still only make sense when `'a` is bound to a
loop, and `break 'a` won't make sense when `'a` is a lifetime parameter. That
means users will need to understand their are three tiers of lifetimes: loop,
block (including `'fn`), and, parameter, where each is less usable than the
last. Today loop lables and lifetimes are disjoint in that neither can be used
where the other is expected, though they do share the same syntax.

What parts of the design are still TBD?

0 comments on commit 041dc18

Please sign in to comment.