Skip to content

Change named arguments syntax to $name = value #192

Open
@stasm

Description

@stasm

This idea hit me when I was working on #176 (comment). It's long bothered me that we use colons : to define values of named arguments. It's different from how the values of messages, terms and attributes are defined.

The reason to use : was to avoid ambiguity with definitions of new messages. This was particularly important in context of the indentation relaxation (#87), where a named argument formatted over multiple lines could produce a false positive for the error recovery:

# Made-up syntax. We couldn't use = for named args because
# in case of a syntax error the error recovery algorithm would 
# see month = as a beginning of a new message.
err-call-expr = {DATETIME($date,
month = "long"

If all named arguments were required to start with the $ sigil, there would be no ambiguity. It also makes sense semantically: named arguments define values of variables used by the function. And we could use the familiar = for defining the values.

# Syntax 0.7
today-is = Today is {DATETIME($date, month: "long", year: "numeric", day: "numeric")}
# This proposal
today-is = Today is {DATETIME($date, $month="long", $year="numeric", $day="numeric")}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions