Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dcl.fct.def.coroutine] Replace "variable" with "object" #4276

Closed
wants to merge 1 commit into from

Conversation

languagelawyer
Copy link
Contributor

No description provided.

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

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

What if T is a reference?

@languagelawyer
Copy link
Contributor Author

Hm, T indeed can be a reference type, so I think it is not possible to reword this paragraph separately

@languagelawyer
Copy link
Contributor Author

languagelawyer commented Oct 5, 2020

Hm. [basic.stc]/2: ... automatic storage durations are associated with objects introduced by declarations ([basic.def]) and implicitly created by the implementation (temporary objects).
[dcl.fct.def.coroutine]/13 says that the copies are the objects with automatic storage duration, but doesn't say that they are introduced by a declaration and I doubt that they are temporary objects. So [basic.stc]/2 misses this case.

Given that it is described how a coroutine's function-body is replaced, maybe we copy parameters syntactically, by injecting variable declarations initialized from parameters before promise-type promise promise-constructor-arguments ; and replacing id-expressions naming parameters with id-expressions naming the corresponding variables in the function-body? This way:

  • there will be no need to fix [basic.stc]/2, because objects will be introduced by declarations
  • it will be possible to remove this wording from [dcl.fct.def.coroutine]/13:

The initialization and destruction of each parameter copy occurs in the context of the called coroutine. Initializations of parameter copies are sequenced before the call to the coroutine promise constructor and indeterminately sequenced with respect to each other. The lifetime of parameter copies ends immediately after the lifetime of the coroutine promise object ends.

  • it will be possible to remove «An identifier that names a coroutine parameter refers to the copy of the parameter.» from [expr.prim.id.unqual]/1

@languagelawyer languagelawyer reopened this Oct 5, 2020
@languagelawyer languagelawyer marked this pull request as draft October 5, 2020 01:07
@zygoloid
Copy link
Member

zygoloid commented Oct 5, 2020

I think we should leave this alone for now, and wait for it to be handled by CWG's split of "object" and "variable".

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.

None yet

3 participants