Repository navigation
Description
The C# Guide and the Visual Basic Guide both contain large sections for "Language Reference"
C# Guide Language Reference
Visual Basic Guide Language Reference
Now that we are publishing the language specification for both languages on docs, I propose updating these sections in a major way. The reason for the major update is that the "language reference" sections contain considerable duplication with the language specs. This causes many problems:
- The language reference sections must be updated along with the specs, many times making the same edits.
- Where the reference sections and the specs have diverged is a source of confusion for customers.
- The language reference is written in a more conversational tone than the language specifications. This introduces some ambiguity, incomplete, or occasionally misleading information.
- The language reference has a different organization than the spec, which makes comparing them for accuracy difficult.
However, the language reference does have many resources that customers use, but are not part of the formal language specifications:
- The language reference has many more examples and sample code than the spec.
- The same conversational tone makes the reference more approachable.
- The samples mentioned above often relate different language features to show common patterns.
I propose that over time, we make the language reference section of the guides into a companion to the language specification, containing more informative examples and commentary, and less duplication with the specification. The reference section would parallel the specification, using the same chapter and section headers. (The "Lexical structure" section may not even be needed in the language reference). For each section, the language reference would contain:
- An introductory paragraph about the language element.
- A link to the pertinent section of the latest language specification
- Examples and usages for the language element.
- Related language reference topics.
From the language reference, readers should get:
- A conversational survey of the language.
- Samples for all language elements
- Examples for typical uses of language elements.
The language reference would not be an alternative presentation of the specification, but rather a companion to the language specification
The Visual Basic Guide also contains a "Reference" section:
Visual Basic Guide Reference
This section contains reference information about the compiler executable: command line options, compiler errors and warnings, preprocessor symbols and so on. Those are folded into the C# Language Reference. I propose moving those sections out of the C# Language Reference section into a C# Reference section, paralleling the Visual Basic organization.
Activity
cartermp commentedon Aug 7, 2017
It sounds like you're proposing that they be similar in content and style to the F# language reference section we have. I think that's a great idea. Basically, every article is about a particular feature (e.g., Modules in VB). In the F# reference we do have a quick section showing the generalized syntax, e.g.
Would that be desirable for C# and VB as well?
BillWagner commentedon Aug 9, 2017
Right @cartermp
Your comment got me thinking more about this. Organizing the Language Reference section this way would make it easy to discuss the history and changes behind features on a feature-by-feature way.
For instance, the
Delegatefeature could discuss the syntax changes in 2.0, 3.0, and so on. Other updates to different features would be treated similarly as new versions are created.agocke commentedon Aug 9, 2017
Are you thinking that the language reference is a kind of exegesis for the spec? My only concern is that we expose people to the spec language too much and they get confused.
AdamSpeight2008 commentedon Aug 9, 2017
The Language Specifications should be akin to datasheets for electronics components.
Each part should be expressible as single side of A4. Just giving you the core vital information.
For example (each leaf will link to a separate "datasheet").
Statements
Statements represent executable code.
Statement ::= LabelDeclarationStatement | LocalDeclarationStatement | WithStatement | SyncLockStatement | EventStatement | AssignmentStatement | InvocationStatement | ConditionalStatement | LoopStatement | ErrorHandlingStatement | BranchStatement | ArrayHandlingStatement | UsingStatement | AwaitStatement | YieldStatementNote. The Microsoft Visual Basic Compiler only allows statements which start with a keyword or an identifier. Thus, for instance, the invocation statement "
Call (Console).WriteLine" is allowed, but the invocation statement "(Console).WriteLine" is not.Control Flow
Control flow is the sequence in which statements and expressions are executed. The order of execution depends on the particular statement or expression.
For example, when evaluating an addition operator (Section Addition Operator), first the left operand is evaluated, then the right operand, and then the operator itself. Blocks are executed (Section Blocks and Labels) by first executing their first substatement, and then proceeding one by one through the statements of the block.
Implicit in this ordering is the concept of a control point, which is the next operation to be executed. When a method is invoked (or "called"), we say it creates an instance of the method. A method instance consists of its own copy of the method's parameters and local variables, and its own control point.
I can quickly scan through it, see that those are the kinds statements supported, If I require more information on a particular kind I can follow the link to that specific section.
Side note that is roughly a sheet of A4 (both side) in print preview,
Applications and Examples for that data are in a separate document eg A Language Guide.
BillWagner commentedon Aug 17, 2017
@agocke When I first put this together, my thinking was that the spec would be the normative information for the language. The docs Language Reference would be more the informative information (to borrow the ECMA and ISO spec terminology).
My plan is that the Language Reference would be where readers would go for two things:
The spec would continue to be the best reference for all the details about language features.
BillWagner commentedon Aug 17, 2017
@AdamSpeight2008 I think we're close to agreement. How's this for an organization:
There are more details under each of those, but does that direction make sense?
AdamSpeight2008 commentedon Aug 17, 2017
@BillWagner
I think we are more or less thinking along the same lines.
If you just parts parts 1 and 2 you theoretically should be able to implement and build the language from the ground up (If one was inclined to do so.). If you have just part 3 you'll get a good working knowledge the language, but not every precise nuance of it.
@agocke We should point most uses to the language guide / reference, as it enough to cover the largest majority of use case. The remaining the minority to the technical specification.
dotnet-bot commentedon Jan 25, 2021
This issue has been closed as part of the issue backlog grooming process outlined in #22351.
That automated process may have closed some issues that should be addressed. If you think this is one of them, reopen it with a comment explaining why. Tag the
@dotnet/docsteam for visibility.