Skip to content

Be more specific about the benefits of P3815#52

Open
jesswong wants to merge 13 commits into
d3815r0from
d3815r1
Open

Be more specific about the benefits of P3815#52
jesswong wants to merge 13 commits into
d3815r0from
d3815r1

Conversation

@jesswong

@jesswong jesswong commented Nov 3, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread 3815.md Outdated

During the development of these sample implementations, it was observed that reintroducing the `scope_association`
concept from [@P3149R7] would yield several benefits:
In [@P3149R7], we also introduced the `scope_association` concept as an RAII handle for managing scope associations. However, this facility was removed in [@P3149R9] due to concerns about the unconventional behavior of its copy constructor. This change was made without implementation experience.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little hesitant to say "this change was made without implementation experience"; did we have experience with the association concept? We might have, but I don't remember.

@jesswong jesswong Nov 3, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the time of LEWG's approval of R9, I don't think we had an implementation of scopes with a scope_association concept. My recollection of when we discovered these issues was when we started working on R10 wording and realized the code looked gross. We then tried implementing the wording with a scope_association concept and realized it was way better.

Maybe I can be more explicit about the fact that because we didn't have implementation experience with scope_assocation at the time of R9's approval, the full consequences of its removal were not yet understood.

Comment thread 3815.md Outdated
```
::::

In the above example, a key difference when implementing _`spawn`_ with a `scope_association` concept is that `t.try_associate()` is invoked in the constructor rather than in `run()`. This change simplifies exception handling within _`spawn`_: if an exception occurs, only the allocation needs to be explicitly cleaned up. By contrast, if `t.try_associate()` throws from `run()`, both destruction and deallocation needs to be explicitly handled.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this text, but I think it's wrong to italicize spawn, right? Or did you mean spawn-state?

Suggested change
In the above example, a key difference when implementing _`spawn`_ with a `scope_association` concept is that `t.try_associate()` is invoked in the constructor rather than in `run()`. This change simplifies exception handling within _`spawn`_: if an exception occurs, only the allocation needs to be explicitly cleaned up. By contrast, if `t.try_associate()` throws from `run()`, both destruction and deallocation needs to be explicitly handled.
In the above example, a key difference when implementing _`spawn-state`_ with a `scope_association` concept is that `t.try_associate()` is invoked in the constructor rather than in `run()`. This change simplifies exception handling within _`spawn-state`_: if an exception occurs, only the allocation needs to be explicitly cleaned up. By contrast, if `t.try_associate()` throws from `run()`, both destruction and deallocation needs to be explicitly handled.

jesswong and others added 11 commits November 3, 2025 12:39
Update th wording with LWG feedback
Move simple_counting_scope::assoc-t into a class template in
[exec.counting.scopes.general] and update the two scopes' assoc-t nested
types to be nested type aliases to the newly-defined class template.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants