Skip to content

Allow trailing comma in parameter list #8873

@lzybkr

Description

@lzybkr

Summary of the new feature/enhancement

Some languages like Rust allow a trailing comma in a parameter or argument list. In PowerShell, this would look like:

param($a,)

Without allowing a trailing comma, some people resort to formatting like the following:

param( [Parameter(Mandatory)][string] $Thing
     , [Parameter()][string] $AnotherThing
     , [Parameter()][string] $YetAnotherThing
)

The "leading" comma syntax gets used to minimize the lines changed when adding new parameters.

If a trailing comma was allowed, this style would be replaced with:

param( [Parameter(Mandatory)][string] $Thing,
       [Parameter()][string] $AnotherThing,
       [Parameter()][string] $YetAnotherThing,
)

This could also be applied to method argument lists:

$something.Insert($offset, $value,)

This usage might see less use than in parameter lists though as parameter lists usually span multiple lines whereas argument lists often do not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-Won't FixThe issue won't be fixed, possibly due to compatibility reason.WG-Languageparser, language semantics

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions