You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The _conditional expression_`if (´e_1´) ´e_2´ else ´e_3´` chooses one of the values of ´e_2´ and ´e_3´, depending on the value of ´e_1´.
@@ -698,6 +703,7 @@ The conditional expression `if (´e_1´) ´e_2´` is evaluated as if it was `if
698
703
699
704
```ebnf
700
705
Expr1 ::= ‘while’ ‘(’ Expr ‘)’ {nl} Expr
706
+
| ‘while’ Expr ‘do’ Expr
701
707
```
702
708
703
709
The _while loop expression_`while (´e_1´) ´e_2´` is typed and evaluated as if it was an application of `whileLoop (´e_1´) (´e_2´)` where the hypothetical method `whileLoop` is defined as follows.
@@ -868,15 +874,19 @@ The type of a throw expression is `scala.Nothing`.
A _try expression_ is of the form `try { ´b´ } catch ´h´` where the handler ´h´ is usually a [pattern matching anonymous function](08-pattern-matching.html#pattern-matching-anonymous-functions)
882
+
A _try expression_ is of the form `try ´b´ catch ´h´` where the handler ´h´ is usually a [pattern matching anonymous function](08-pattern-matching.html#pattern-matching-anonymous-functions)
875
883
876
884
```scala
877
885
{ case ´p_1´ => ´b_1´ ... case ´p_n´ => ´b_n´ }
878
886
```
879
887
888
+
If the handler is a single `ExprCaseClause`, it is a shorthand for that `ExprCaseClause` wrapped in a pattern matching anonymous function.
889
+
880
890
This expression is evaluated by evaluating the block ´b´.
881
891
If evaluation of ´b´ does not cause an exception to be thrown, the result of ´b´ is returned.
882
892
Otherwise the handler ´h´ is applied to the thrown exception.
@@ -885,22 +895,22 @@ If the handler contains no case matching the thrown exception, the exception is
885
895
More generally, if the handler is a `PartialFunction`, it is applied only if it is defined at the given exception.
886
896
887
897
Let ´\mathit{pt}´ be the expected type of the try expression.
888
-
The block ´b´ is expected to conform to ´\mathit{pt}´.
898
+
The expression ´b´ is expected to conform to ´\mathit{pt}´.
889
899
The handler ´h´ is expected conform to type `scala.Function[scala.Throwable, ´\mathit{pt}\,´]`.
890
900
The type of the try expression is the [weak least upper bound](03-types.html#weak-conformance) of the type of ´b´ and the result type of ´h´.
891
901
892
-
A try expression `try { ´b´ } finally ´e´` evaluates the block ´b´.
902
+
A try expression `try ´b´ finally ´e´` evaluates the expression ´b´.
893
903
If evaluation of ´b´ does not cause an exception to be thrown, the expression ´e´ is evaluated.
894
904
If an exception is thrown during evaluation of ´e´, the evaluation of the try expression is aborted with the thrown exception.
895
905
If no exception is thrown during evaluation of ´e´, the result of ´b´ is returned as the result of the try expression.
896
906
897
907
If an exception is thrown during evaluation of ´b´, the finally block ´e´ is also evaluated.
898
908
If another exception ´e´ is thrown during evaluation of ´e´, evaluation of the try expression is aborted with the thrown exception.
899
909
If no exception is thrown during evaluation of ´e´, the original exception thrown in ´b´ is re-thrown once evaluation of ´e´ has completed.
900
-
The block ´b´ is expected to conform to the expected type of the try expression.
910
+
The expression ´b´ is expected to conform to the expected type of the try expression.
901
911
The finally expression ´e´ is expected to conform to type `Unit`.
902
912
903
-
A try expression `try { ´b´ } catch ´e_1´ finally ´e_2´` is a shorthand for `try { try { ´b´ } catch ´e_1´ } finally ´e_2´`.
913
+
A try expression `try ´b´ catch ´e_1´ finally ´e_2´` is a shorthand for `try { try ´b´ catch ´e_1´ } finally ´e_2´`.
0 commit comments