Conversation
|
|
||
| .. _fls_G64vdcIyB2Is: | ||
|
|
||
| Closure capture precision |
There was a problem hiding this comment.
You may want to rename this section "Capture precision", similar to the Reference, and make it subheading of 6.22. Capturing.
There was a problem hiding this comment.
heh, I missed that 6.22 even existed :hide:
| Closure capture precision | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| :dp:`fls_rdDT7jsaOMbs` |
There was a problem hiding this comment.
This paragraph should be swapped with :dp:fls_j9WyKVyOLFon. The FLS avoids forward referencing as much as possible. Here you are using the term "place projection", but you have not defined it yet.
| A :dt:`place projection` is a :t:`field access expression`, tuple :t:`field access expression`, :t:`dereference`, array or slice :t:`index expression`, or :t:`pattern` destructuring applied to a variable. | ||
|
|
||
| :dp:`fls_TbfUxVf8PKPs` | ||
| The closure :t:`[borrow]s` or :t:`moves <by move>` the :t:`capture path`, which may be truncated based on these rules: |
There was a problem hiding this comment.
How about
A :t:closure expression :t:[borrow]s or :t:moves <by move> the :t:capture path, as follows:
| The closure :t:`[borrow]s` or :t:`moves <by move>` the :t:`capture path`, which may be truncated based on these rules: | ||
|
|
||
| - :dp:`fls_4TESOxGpEY2h` | ||
| When a :t:`capture path` and one of the ancestors of that path are both captured by a closure, the ancestor path is captured with the highest capture mode among the two captures, using the strict weak ordering: :t:`immutable borrow` < :t:`unique immutable borrow` < :t:`mutable borrow` < :t:`move <by move>`. |
There was a problem hiding this comment.
It is unclear what an "ancestor" is. Be careful when using the term "path", because we also have these paths. What the Reference describes is already documented in 6.22:12 The capture mode ....
I would rephrase the paragraph as follows (note that it is part of a list!):
- When a :t:
capture pathand an ancestor :t:capture pathand both :t:captured, the ancestor :t:capture pathis :t:capturedwith the highest :t:capture modeamong the two :t:[capture path]s.
Note that I intentionally dropped "by a closure" because a "capturing expression" is either an async block expression or a closure expression, and I suspect that these rules do apply when the context is an async block expression.
I also dropped the ordering because it is already documented by "capture mode". On a side note, perhaps 6.22:14 should be changed to "1. By immutable reference capture. (lowest precedence)" and 6:22:17 to "4. By value capture. (highest precedence)", or just use a small table similar to expression precedence.
| The :t:`capture path` is truncated at the rightmost :t:`dereference` in the capture path if the dereference is applied to a :t:`shared reference`. | ||
|
|
||
| :dp:`fls_v8IFXHJnXhez` | ||
| A :t:`place` is not captured when an :t:`underscore expression` is used to bind it. |
There was a problem hiding this comment.
The Reference is unclear what "place" refers to - is it a "place projection", a "place expression", or a "place". I suspect the former, but this needs confirmation. Once that is cleared up, there are options to refactor some of the rules below.
Co-authored-by: Hristian Kirtchev <60669983+kirtchev-adacore@users.noreply.github.com>
Co-authored-by: Hristian Kirtchev <60669983+kirtchev-adacore@users.noreply.github.com>
e3ed8e9 to
7be2ad5
Compare
|
all addressed but #698 (comment) |
This captures some gaps FLS has compared to Reference, and the content is adjusted from Closure capture precision section.