Skip to content

Add formatter rule to normalize keyword-argument sugar #963

@ultimatile

Description

@ultimatile

Julia supports keyword-argument syntax sugar where a bare identifier (or dot expression) after ; implies the keyword name:

When a bare identifier or dot expression occurs after a semicolon, the keyword argument name is implied by the identifier or field name. For example plot(x, y; width) is equivalent to plot(x, y; width=width) and plot(x, y; options.width) is equivalent to plot(x, y; width=options.width).

(quoted from the Julia manual: https://docs.julialang.org/en/v1/manual/functions/#Keyword-Arguments)

Both styles (plot(x, y; width) and plot(x, y; width=width)) can appear in my codebases, and I would like to unify them automatically via a formatter rule.

Request

Add an option/rule to normalize this syntax:

  • Prefer the sugar form: f(; x=x)f(; x)
  • Or prefer the explicit form: f(; x)f(; x=x)

I apologize if I have overlooked existing options or prior discussions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions