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
C# Programming guide: Top-level statements #23234
C# Programming guide: Top-level statements #23234
Changes from 4 commits
4f49533
0fc1b4b
22155f4
ccea1b3
a811f38
9353918
c9bf7ee
5168b47
2ca6d58
fddbebe
383f32d
8a9f5ea
5f7e6fe
6dca758
3d85dcd
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.
Is "and" extra?
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 was intentional, as these are two different options -- top-level statements (implicit Main) and explicit Main. But I'll change "and" to "or" as that may be clearer.
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.
The feature is also known as "simple programs" if I recall correctly. You may want to include this name for SEO purposes.
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.
Where did you see this name?
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.
Frequently used in Roslyn repo
For example:
https://github.com/dotnet/roslyn/blob/main/src/Compilers/CSharp/Portable/Symbols/Synthesized/SynthesizedSimpleProgramEntryPointSymbol.cs
https://github.com/dotnet/roslyn/issues?q=is%3Aopen+is%3Aissue+label%3A%22New+Language+Feature+-+Simple+Programs%22
Probably ask Roslyn team for guidance whether this name should be advertised in docs?
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.
The public messaging has been consistently to call this feature "top-level statements," and with "simple programs" showing up only in the Roslyn repo, I think using that as an alternate feature name would be unnecessarily confusing, but I'll follow the lead of the top-level statements tutorial and work in the phrase "simple programs" into 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.
"Top level statements" is the official name. The product team followed our lead here to avoid the use of "simple". The goal is that programs that use "top level statements" need not be "simple". See FeatherApp for one example of possibilities.
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 personally lean towards using main without backticks instead of
Main
. Because the method the compiler generates isn't calledMain
, but<Main>$
.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 think "implicit" clarifies the status of
Main
, but in this instance it will be clearer to repeat "implicit" directly before Main.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 "implicit" resolves this. It could be implicit and called
Main
, but the compiler implementation decided it's called<Main>$
.And actually, from a compiler-point of view, it's not implicit at all (see discussion at dotnet/roslyn#48199), but it's okay to mention implicit for the purpose of this article I think?
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.
As I mentioned in the other thread, I'll add an explanation that the actual generated name is an implementation detail.
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 like this table. See my previous comment about the return value of
Main
. Adding this table there would be perfect.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.
Adding a slightly modified table to both the return value and command-line args docs.
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'd add a link to the top level statements speclet. The link would be
~/_csharplang/proposals/csharp-9.0/top-level-statements.md