Skip to content

Standardize statement block/script block terminology #12608

@surfingoldelephant

Description

@surfingoldelephant

Prerequisites

  • Existing Issue: Search the existing issues for this repository. If there is an issue that fits your needs do not file a new one. Subscribe, react, or comment on that issue instead.
  • Descriptive Title: Write the title for this issue as a short synopsis. If possible, provide context. For example, "Typo in Get-Foo cmdlet" instead of "Typo."
  • Verify Version: If there is a mismatch between documentation and the behavior on your system, ensure that the version you are using is the same as the documentation. Check this box if they match or the issue you are reporting is not version specific.

Links

Summary

Statement block/script block terminology is inconsistent throughout the docs.

Details

Script block vs statement block

There are various instances throughout the documentation in which a statement block is incorrectly referred to as a script block. For example (non-exhaustive):

Semantically, statement blocks are very different to script blocks and using the terms interchangeably is bound to cause confusion. I've seen cases where users were under impression that variable assignments don't persist outside the context of an if, switch, etc statement because some docs use the term "script block" in relation to these constructs.

Script block vs scriptblock

Referring to a script block in a general sense (i.e., not specifically as a type) is inconsistent. The docs are currently split on "script block" and "scriptblock". It should, in my opinion, be:

  • "script block" when referring to it in a general sense (matches about_Script_Blocks)
  • ScriptBlock/System.Management.Automation.ScriptBlock when referring to the type name/fullname itself
  • [scriptblock] when referring to the type accelerator

Suggested Fix

  • Correct all instances in which a statement block is referred to as a script block.
  • Standardize the term "script block" throughout the docs.
  • In about_Script_Blocks:
    • Note the differences between a script block and a statement block, such as scope creation and automatic variable management.
  • In about_Parsing:
    • Note that in expression mode, {...} is parsed as a statement block when a language keyword is encountered. In argument mode or with variable assignment, it's parsed as a script block (literal).
    • Add a new section on whitespace differences between expression mode and argument mode.
      • A statement block's opening { can be placed on a new line due to whitespace insignificance in expression mode.
      • Like all arguments, a script block in argument mode must be on the same line as the parameter.
    • Correct the typo here ("begin a new script blocks" -> "begin a new script block").

I have a couple of write-ups here and here on the subject.

Metadata

Metadata

Assignees

No one assigned

    Labels

    issue-doc-bugIssue - error in documentationneeds-triageWaiting - Needs triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions