Skip to content

Three syntaxes for initialising auto-typed variables#2618

Merged
colin-home merged 3 commits into
MicrosoftDocs:masterfrom
yecril71pl:patch-1
Jan 8, 2021
Merged

Three syntaxes for initialising auto-typed variables#2618
colin-home merged 3 commits into
MicrosoftDocs:masterfrom
yecril71pl:patch-1

Conversation

@yecril71pl

Copy link
Copy Markdown
Contributor

The initialisation expression can be an assignment but that means a = b = 0.
The initialisation expression can involve operator new but it is not a separate case. Compare auto a = new int; and auto a (new int);. There is no initialisation statement inherently involving operator new (unlike in Visual Basic).
The fact that a for loop involves an initialisation statement is a side note at best. This trivia fact is not specific to auto.
The parenthesised "explanations" explained one unknown with another unknown. I replaced them with short examples.

The initialisation expression can be an assignment but that means `a = b = 0`.
The initialisation expression can involve `operator new` but it is not a separate case. Compare `auto a = new int;` and `auto a (new int);`.  There is no initialisation statement inherently involving `operator new` (unlike in Visual Basic).
The fact that a `for` loop involves an initialisation statement is a side note at best.  This trivia fact is not specific to `auto`.
The parenthesised "explanations" explained one unknown with another unknown.  I replaced them with short examples.
@PRMerger13

Copy link
Copy Markdown
Contributor

@yecril71pl : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@colin-home

Copy link
Copy Markdown
Contributor

@yecril71pl
Thanks for your considered input. I'm not sure why new was called out either. Your updated explanation is correct as far as it goes, but it's missing a mention of auto and the uniform initialization syntax. We do mention it later, but it probably should be included here, too. It's safe to defer talk about how auto will create a std::initializer_list from a braced initializer at any opportunity. And there's a reason the range-based for loop syntax gets a call-out, since it's an auto syntax variation that doesn't appear elsewhere. I will think about this, but not for a while, since I'm on vacation for a week.

According to the maintainer’s comments.
@PRMerger8

Copy link
Copy Markdown
Contributor

@yecril71pl : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@yecril71pl yecril71pl changed the title Two syntaxes for initialising auto-typed variables Three syntaxes for initialising auto-typed variables Nov 23, 2020
@yecril71pl

yecril71pl commented Nov 23, 2020

Copy link
Copy Markdown
Contributor Author

And there's a reason the range-based for loop syntax gets a call-out, since it's an auto syntax variation that doesn't appear elsewhere.

I formally disagree but I have restored it since it is a typical use case. You may have to adapt the terminology though. Have a nice holiday! :-)

@ktoliver ktoliver added the aq-pr-triaged Tracking label for the PR review team label Nov 23, 2020
It seemed to call out for a list, since the sentence was getting complicated.
@PRMerger20

Copy link
Copy Markdown
Contributor

@corob-msft : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@colin-home colin-home left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@yecril71pl
Thanks for your patience. I appreciate your contribution, even though I've substantially rewritten it to make our grammar checker happy. I'll merge this version. You're welcome to submit additional changes as PRs if you think more clarity is needed.

@colin-home colin-home merged commit 3c41d14 into MicrosoftDocs:master Jan 8, 2021
@yecril71pl yecril71pl deleted the patch-1 branch January 13, 2021 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants