Skip to content

Commit 1aaa83b

Browse files
committed
---
yaml --- r: 62543 b: refs/heads/snap-stage3 c: b71a1ec h: refs/heads/master i: 62541: 11829c3 62539: c60b062 62535: dc9a0b7 62527: a655b93 v: v3
1 parent a407fcb commit 1aaa83b

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 999f6926459294136b623b101c8a033ec8ec29db
4+
refs/heads/snap-stage3: b71a1ecea2de87cff3089f9f261be71cd314aac9
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/doc/rust.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,6 +2250,14 @@ do_expr : "do" expr [ '|' ident_list '|' ] ? '{' block '}' ;
22502250
A _do expression_ provides a more-familiar block-syntax for a [lambda expression](#lambda-expressions),
22512251
including a special translation of [return expressions](#return-expressions) inside the supplied block.
22522252

2253+
Any occurrence of a [return expression](#return-expressions)
2254+
inside this `block` expression is rewritten
2255+
as a reference to an (anonymous) flag set in the caller's environment,
2256+
which is checked on return from the `expr` and, if set,
2257+
causes a corresponding return from the caller.
2258+
In this way, the meaning of `return` statements in language built-in control blocks is preserved,
2259+
if they are rewritten using lambda functions and `do` expressions as abstractions.
2260+
22532261
The optional `ident_list` and `block` provided in a `do` expression are parsed as though they constitute a lambda expression;
22542262
if the `ident_list` is missing, an empty `ident_list` is implied.
22552263

@@ -2296,19 +2304,15 @@ A _for expression_ is similar to a [`do` expression](#do-expressions),
22962304
in that it provides a special block-form of lambda expression,
22972305
suited to passing the `block` function to a higher-order function implementing a loop.
22982306

2299-
Like a `do` expression, a `return` expression inside a `for` expresison is rewritten,
2300-
to access a local flag that causes an early return in the caller.
2301-
2302-
Additionally, any occurrence of a [return expression](#return-expressions)
2303-
inside the `block` of a `for` expression is rewritten
2304-
as a reference to an (anonymous) flag set in the caller's environment,
2305-
which is checked on return from the `expr` and, if set,
2306-
causes a corresponding return from the caller.
2307-
In this way, the meaning of `return` statements in language built-in control blocks is preserved,
2308-
if they are rewritten using lambda functions and `do` expressions as abstractions.
2307+
In contrast to a `do` expression, a `for` expression is designed to work
2308+
with methods such as `each` and `times`, that require the body block to
2309+
return a boolean. The `for` expression accommodates this by implicitly
2310+
returning `true` at the end of each block, unless a `break` expression
2311+
is evaluated.
23092312

2310-
Like `return` expressions, any [`break`](#break-expressions) and [`loop`](#loop-expressions) expressions
2311-
are rewritten inside `for` expressions, with a combination of local flag variables,
2313+
In addition, [`break`](#break-expressions) and [`loop`](#loop-expressions) expressions
2314+
are rewritten inside `for` expressions in the same way that `return` expressions are,
2315+
with a combination of local flag variables,
23122316
and early boolean-valued returns from the `block` function,
23132317
such that the meaning of `break` and `loop` is preserved in a primitive loop
23142318
when rewritten as a `for` loop controlled by a higher order function.

0 commit comments

Comments
 (0)