Skip to content

Pattern-esque syntax for terser named arguments/record fields #3102

@nex3

Description

@nex3

The pattern-matching syntax introduces the constructs :var foo and :foo to declare a variable whose name matches a field on the object being matched. The purpose of this is to reduce duplication, to users don't have to explicitly write foo: var foo.

I propose using this syntax as a way to reduce duplication when passing named arguments (or constructing records). Specifically, make foo(:argument) equivalent to foo(argument: argument). Similarly, record literals could be declared using (:field) instead of (field: field). This would help reduce duplication and ease acclimation to Dart for users coming from JS, which supports similar behavior when using maps as named arguments (in JS, foo({argument}) is equivalent to foo({argument: argument})).

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureProposed language feature that solves one or more problems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions