@@ -61,11 +61,11 @@ Naturally, in this case the types of the "exceptions thrown by" `foo()` and
61
61
` bar() ` must unify. Like the current ` try!() ` macro, the ` ? ` operator will also
62
62
perform an implicit "upcast" on the exception type.
63
63
64
- When used outside of a ` try ` block, the ` ? ` operator propagates the exception to
64
+ When used outside of a ` catch ` block, the ` ? ` operator propagates the exception to
65
65
the caller of the current function, just like the current ` try! ` macro does. (If
66
66
the return type of the function isn't a ` Result ` , then this is a type error.)
67
- When used inside a ` try ` block, it propagates the exception up to the innermost
68
- ` try ` block, as one would expect.
67
+ When used inside a ` catch ` block, it propagates the exception up to the innermost
68
+ ` catch ` block, as one would expect.
69
69
70
70
Requiring an explicit ` ? ` operator to propagate exceptions strikes a very
71
71
pleasing balance between completely automatic exception propagation, which most
@@ -203,7 +203,7 @@ are merely one way.
203
203
Err(e) => break 'here Err(e.into())
204
204
}
205
205
206
- Where ` 'here ` refers to the innermost enclosing ` try ` block, or to ` 'fn ` if
206
+ Where ` 'here ` refers to the innermost enclosing ` catch ` block, or to ` 'fn ` if
207
207
there is none.
208
208
209
209
The ` ? ` operator has the same precedence as ` . ` .
@@ -247,21 +247,18 @@ items.
247
247
248
248
Without any attempt at completeness, here are some things which should be true:
249
249
250
- * ` try { foo() } ` = ` Ok(foo()) `
251
- * ` try { Err(e)? } ` = ` Err(e.into()) `
252
- * ` try { try_foo()? } ` = ` try_foo().map_err(Into::into) `
253
- * ` try { Err(e)? } catch { e => e } ` = ` e.into() `
254
- * ` try { Ok(try_foo()?) } catch { e => Err(e) } ` = ` try_foo().map_err(Into::into) `
250
+ * ` catch { foo() } ` = ` Ok(foo()) `
251
+ * ` catch { Err(e)? } ` = ` Err(e.into()) `
252
+ * ` catch { try_foo()? } ` = ` try_foo().map_err(Into::into) `
255
253
256
254
(In the above, ` foo() ` is a function returning any type, and ` try_foo() ` is a
257
255
function returning a ` Result ` .)
258
256
259
257
## Feature gates
260
258
261
- The two major features here, the ` ? ` syntax and the ` try ` /` catch `
262
- syntax, will be tracked by independent feature gates. Each of the
263
- features has a distinct motivation, and we should evaluate them
264
- independently.
259
+ The two major features here, the ` ? ` syntax and ` catch ` expressions,
260
+ will be tracked by independent feature gates. Each of the features has
261
+ a distinct motivation, and we should evaluate them independently.
265
262
266
263
# Unresolved questions
267
264
@@ -435,11 +432,9 @@ standard monadic bind to accommodate rich control flow like `break`,
435
432
436
433
* Don't.
437
434
438
- * Only add the ` ? ` operator, but not ` try ` and ` try ` .. ` catch ` .
435
+ * Only add the ` ? ` operator, but not ` catch ` expressions .
439
436
440
- * Only add ` ? ` and ` try ` , but not ` try ` ..` catch ` .
441
-
442
- * Instead of a built-in ` try ` ..` catch ` construct, attempt to define one using
437
+ * Instead of a built-in ` catch ` construct, attempt to define one using
443
438
macros. However, this is likely to be awkward because, at least, macros may
444
439
only have their contents as a single block, rather than two. Furthermore,
445
440
macros are excellent as a "safety net" for features which we forget to add
@@ -477,7 +472,7 @@ It is possible to carry the exception handling analogy further and also add
477
472
478
473
` throw ` is very simple: ` throw EXPR ` is essentially the same thing as
479
474
` Err(EXPR)? ` ; in other words it throws the exception ` EXPR ` to the innermost
480
- ` try ` block, or to the function's caller if there is none.
475
+ ` catch ` block, or to the function's caller if there is none.
481
476
482
477
A ` throws ` clause on a function:
483
478
0 commit comments