Skip to content

Commit bae487a

Browse files
committed
---
yaml --- r: 60546 b: refs/heads/auto c: b71a1ec h: refs/heads/master v: v3
1 parent de00844 commit bae487a

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
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 999f6926459294136b623b101c8a033ec8ec29db
17+
refs/heads/auto: b71a1ecea2de87cff3089f9f261be71cd314aac9
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/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)