Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Comments #198
Comments #198
Changes from 6 commits
d761200
d669407
3a94646
3f40a76
d99353c
7cbac4c
c1c9f4d
ac5c1e9
9e21253
ef1f702
2f34c67
c13428f
03d760f
4473b58
55a0187
bc2e9fc
81a5297
a55103b
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth saying something about what an automatic C++-to-Carbon translator should do with comments under this proposal, given the more restrictive placement. (Or is the idea that we shouldn't expect C++ comments to get transferred to the Carbon version verbatim?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I have a solid answer here, but I do think it's important that we translate comments in the common case.
Comments at the start of a line seem straightforward to translate, and I'd imagine we'd make a policy decision that we produce documentation whenever a comment appears at a suitable position. Trailing comments seem slightly harder, because there's the risk that they aren't directly associated with the line to the left:
But I think we can get a 95+% conversion by moving these comments before their declarations.
Comments in unusual places (specifically, neither at the beginning nor at the end of a statement) seem likely to cause problems for translation irrespective of whether we permit intra-line / block / trailing comments in Carbon. I don't really have a good answer there. Tracking where they are in the C++ AST and mapping that into the Carbon AST seems like it may be infeasible in general. I expect such comments would also be a problem when migrating between versions of Carbon, although likely less so, because we'll hopefully mostly be doing localized rewrites rather than full-source-file rewrites.
I'm happy to include something along these lines in the proposal, though I wonder how much detail we should go into here versus in a proposal more targeted at migration. Maybe this is something we should be systematically asking of all proposals involving language syntax?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're probably right that this is something we should be systematically asking of all proposals involving language syntax. Or to make a slightly weaker claim: this is something we should be systematically asking of proposals involving language syntax in all cases where there's reason to think translation might be problematic.
I asked in this case because the proposed Carbon comment syntax is more restrictive than the existing C++ comment syntax, which makes me wonder if there would always be a good Carbon translation for C++ comments. I think there's a chance, once we start writing a C++-to-Carbon translator, that we'll find it's easiest to allow Carbon comments in all of the places where C++ comments are allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because it doesn't start at the beginning of the line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clarify that in the text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved by removal of this section.