Skip to content

Updated focus for the "Language Reference" sections #2840

Closed

Description

@BillWagner

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

  1. added
    discussion
    on Aug 5, 2017
  2. added this to the Backlog milestone on Aug 7, 2017
  3. cartermp commented on Aug 7, 2017

    @cartermp
    Contributor

    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.

    // Top-level module declaration.
    module [accessibility-modifier] [qualified-namespace.]module-name
    declarations
    // Local module declaration.
    module [accessibility-modifier] module-name =
        declarations

    Would that be desirable for C# and VB as well?

  4. BillWagner commented on Aug 9, 2017

    @BillWagner
    MemberAuthor

    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 Delegate feature 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.

  5. agocke commented on Aug 9, 2017

    @agocke
    Member

    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.

  6. AdamSpeight2008 commented on Aug 9, 2017

    @AdamSpeight2008

    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
     | YieldStatement

    Note. 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.

    • Methods
    • Blocks and Labels
    • Local Declaration Statements
      • Implicit Local Declarations
    • SyncLock Statement
    • Event Statements
      • RaiseEvent Statement
      • AddHandler and RemoveHandler Statements
    • Assignment Statments
      • Regular Assignment Statements
      • Compound Assignment Statements
      • Mid Assignment Statement
    • Invocation Statements
    • Conditional Statements
      • If...Then...Else Statements
      • Select Case Statements
    • Loop Statements
      • While...End While and Do...Loop Statements
      • For Each...Next Statements
    • Exception-Handling Statements
      • Structured Exception-Handling Statements
        • Finally Blocks
        • Catch Blocks
        • Throw Statement
      • Unstructured Error Handling Statements
        • Error Statement
        • On Error Statement
        • Resume Statement
    • Branch Statements
    • Array-Handling Statements
      • ReDim Statement
      • Erase Statement
    • Using statement
    • Await Statement
    • Yield Statement

    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.

  7. BillWagner commented on Aug 17, 2017

    @BillWagner
    MemberAuthor

    @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:

    1. See examples of a feature in use.
    2. Point me to scenarios where this feature is useful.

    The spec would continue to be the best reference for all the details about language features.

  8. BillWagner commented on Aug 17, 2017

    @BillWagner
    MemberAuthor

    @AdamSpeight2008 I think we're close to agreement. How's this for an organization:

    • The spec is the standard where the language is defined.
    • The language reference is a reference to each feature, along with short examples and brief descriptions of when a feature would be useful.
    • The language guide is more scenario based, how to solve different classes of problems using C#. (Consider How To topics, and Tutorials here)

    There are more details under each of those, but does that direction make sense?

  9. AdamSpeight2008 commented on Aug 17, 2017

    @AdamSpeight2008

    @BillWagner
    I think we are more or less thinking along the same lines.

    • 1, Grammar
      • Bare Bones.
      • No examples
      • Aim: Should be able to do a diff and see what has changed from one version to the next.
    • 2a. Technical Language Specification
      • Uses precise language,
      • Defines the semantics of the language.
        • Could use special notation to help with that precise definition.
        • Provide a minimal guide to that notation.
        • What is allowed.
        • What isn't allowed.
        • Possibly with rationale why it isn't.
      • Uses the minimal examples to convey a concept or definition.
      • Target audience is Language Designers / Experts / Gurus / White Beards.
      • eg how Async is technically implemented by language.
    • 2b. Error Code / Exception Guide
      • Guide to all of the errors codes that can be produced by the language.
      • Examples of how they arise.
    • 2c. Roslyn Technical Specification
      • Technical information on the roslyn language structures (Node, Tokens ...)
      • Examples of how to build language constructs from the nodes up.
      • Code Analysis
      • Code Diagnostics
    • 3, Language Guide / Reference
      • It is guide, not a schematic.
      • Target Audience competent / advanced programmers.
      • All of the language features have
        • Brief definition
        • Use case examples.
        • Or real world examples.
      • Doesn't include the more technical information, or the language grammar.

    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.

  10. added and removed
    discussion
    on Mar 6, 2018
  11. added
    won't fix
    on Jan 25, 2021
  12. dotnet-bot commented on Jan 25, 2021

    @dotnet-bot
    Contributor

    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/docs team for visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    won't fix

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions