Description
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
intounquoted-string
andunquoted-numeric
. - Change
literal-expression
to"{" [s] (quoted / unquoted-numeric) [s annotation] [s] "}"