Skip to content

Commit 7f51a17

Browse files
Add Dropped Feature doc page
1 parent 4c813c1 commit 7f51a17

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
layout: doc-page
3+
title: Deprecated: Nonlocal Returns
4+
---
5+
6+
Returning from nested anonymous functions has been deprecated. Nonlocal returns are implemented by throwing and catching `scala.runtime.NonLocalReturnException`-s. This is rarely what is intendant by the programmer. It can be problematic because of the hidden performance cost of throwing and catching exceptions. Furthermore, it is a leaky implementation: a catch-all exception handler can intercept a `NonLocalReturnException`.
7+
8+
A drop-in library replacement is provided in `scala.util.control.NonLocalReturns`:
9+
10+
```scala
11+
import scala.util.control.NonLocalReturns._
12+
13+
returning { ... throwReturn(x) ... }
14+
```

docs/sidebar.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ sidebar:
159159
url: docs/reference/dropped-features/auto-apply.html
160160
- title: Weak Conformance
161161
url: docs/reference/dropped-features/weak-conformance.html
162+
- title: Nonlocal Returns
163+
url: docs/reference/dropped-features/nonlocal-returns.html
162164
- title: Contributing
163165
subsection:
164166
- title: Getting Started

0 commit comments

Comments
 (0)