Skip to content

Commit 3e1abc3

Browse files
Apply suggestions from code review
Co-authored-by: Natsu Kagami <natsukagami@gmail.com>
1 parent a7bcfbb commit 3e1abc3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/_docs/reference/experimental/capture-checking/polymorphism.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ results in the order in which the futures complete. Using an explicit capture va
106106
signature expresses that the cumulative capture set of the input futures is preserved in the
107107
resulting stream:
108108
```scala
109-
def collect[T, C^](fs: Set[Future[T]]^{C})(using Async^): Stream[Future[T]^{C}] =
109+
def collect[T, C^](fs: Set[Future[T]^{C}])(using Async^): Stream[Future[T]^{C}] =
110110
val channel = Channel()
111111
fs.forEach.(_.onComplete(v => channel.send(v)))
112112
Stream.of(channel)

docs/_docs/reference/experimental/capture-checking/scoped-caps.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ Each capability has a _level_ corresponding to the local `cap` of its defining s
5050
- **Methods** (but not accessors or constructors)
5151

5252
Local values like `f1`, `f2`, `ref`, etc., don't define their own levels. They inherit the level of their enclosing method or class. For example, this means:
53-
- `f1` is at `Outer`'s level, i.e., `f` subcaptures local `cap₁`.
53+
- `f1` is at `Outer`'s level, i.e., `f1` subcaptures local `cap₁`.
5454
- `f2` and `ref` are both at `method`'s level, i.e., both subcapture local `cap₂`.
55-
- By lexical lifetime, `{cap₂} <: {cap₃}` holds, but it does **not** hold that `{cap₃} <: {cap₂}`. Hence,
55+
- By lexical nesting, `{cap₂} <: {cap₃}` holds, but it does **not** hold that `{cap₃} <: {cap₂}`. Hence,
5656
we cannot assign the closure to `ref`, because `{f3}` is subcapture-bounded by `{cap₃}`.
5757

5858
### Charging Captures
@@ -248,7 +248,7 @@ Here the closure's local `cap` can absorb `f` because both are nested within `ou
248248

249249
## Comparison with Rust Lifetimes
250250

251-
Readers familiar with Rust may notice similarities to lifetime checking. Both systems prevent references from escaping their valid scope. In Rust, a reference type `&'a T` carries an explicit lifetime parameter `'a`. In Scala's capture checking, the lifetime is folded into the capability name itself: `T^{x}` says "a `T` capturing `x`," and `x`'s level implicitly determines how long this reference is valid. A capture set then acts as an upper bound on the lifetimes of all the capabilities it contains.
251+
Readers familiar with Rust may notice similarities to lifetime checking. Both systems prevent references from escaping their valid scope. In Rust, a reference type `&'a T` carries an explicit lifetime parameter `'a`. In Scala's capture checking, the lifetime is folded into the capability name itself: `T^{x}` says "a `T` capturing `x`," and `x`'s level implicitly determines how long this reference is valid. A capture set of a reference then acts as an upper bound of the reference itself: it only lives as long as all the capabilities it contains are visible.
252252

253253
Consider a `withFile` pattern that ensures a file handle doesn't escape:
254254

0 commit comments

Comments
 (0)