Skip to content

Forbid unquoted non-numeric literals as expression operands #518

Closed
@stasm

Description

@stasm

I propose that we restrict the literal syntax and disallow unquoted non-numeric literals as expression operands.

Today, literals (quoted and unquoted) can appear in 3 positions:

  • as variant keys,
  • as option values,
  • as expression operands.

The first two positions are common and well justified. OTOH, I posit that the third position is very rare, except numeric values. In fact, I'm not aware of strong use-cases for unquoted non-numeric literals as expression operands. Furthermore, I'm concerned about the risk of confusing such unquoted literals for keywords.


Forbidding unquoted non-numeric literals as expression operands will provide two benefits:

  • Since our syntax uses keywords positioned at the front of a declaration, unquoted literals as expression operands may be confused for novel keywords. Consider:

    {now :datetime} vs. {|now| :datetime}
    {error :msgref} vs. {|error| :msgref}
    

    |now| and |error| are clearly recognizable as literal values.

  • It would open new opportunities for introducing new placeholder or expression syntax: {foo}. See Open/close design: A familiar HTML-like syntax as an alternative #516 for an example use-case.

As a reminder, {5 :number} would still be valid under this proposal, as well as :func opt=unquoted and when unquoted.


ABNF-wise, I think we'd need the following two changes:

  • Split unquoted into unquoted-string and unquoted-numeric.
  • Change literal-expression to "{" [s] (quoted / unquoted-numeric) [s annotation] [s] "}"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Agenda+Requested for upcoming teleconferencesyntaxIssues related with syntax or ABNF

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions