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

Extend control-flow declarations to preserve memory management? #17575

Open
vasslitvinov opened this issue Apr 16, 2021 · 1 comment
Open

Extend control-flow declarations to preserve memory management? #17575

vasslitvinov opened this issue Apr 16, 2021 · 1 comment

Comments

@vasslitvinov
Copy link
Member

vasslitvinov commented Apr 16, 2021

This is a fork-off from #13639 (comment)
"Control-flow declarations" were formerly called "if-var" and "while-var", introduced in #17047 and #17304.

Right now the control-flow variable borrows from the control-flow expression of an owned or shared type:

var myC = new shared C();
if const temp = myC {
  // here 'temp' is a borrowed C
}

This issue request allowing such temp to preserve the memory management of the control-flow expression, rather than borrowing from it:

var myC = new shared C();
if const temp = /* Please share the ownership with me. -User */ myC { 
  // here 'temp' is a shared C
}

One possible syntax for this is to have the user specify the type of the temp, with the semantics of a cast from myC to that type, for example:

var myC = new shared C();
if const temp: shared = myC { 
  // here 'temp' is a shared C
}
@bradcray
Copy link
Member

I think this is a reasonable direction, but would probably opt to file it away until someone has a pressing use-case for it.

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

No branches or pull requests

2 participants