Skip to content

Data model feedback: I think we should have string and numeric literals #712

Closed
@mihnita

Description

@mihnita

At this point the data model only has string literals:

interface Literal {
  type: "literal";
  value: string;
}

The parser also has number-literal

literal        = quoted / unquoted
quoted         = "|" *(quoted-char / quoted-escape) "|"
unquoted       = name / number-literal

When we format a message we use the data model only.
Which means there is no way to tell the difference between "...{|123456789|}..." and "...{123456789}..."
Because in the data model we only have a string, and "The presence or absence of quotes is not preserved by the data model."

But I think one would expect that {|123456.789|} to result in "123456.789" (because it is a string),
and would expect {123456.789} formatted as "123,456.789" (or "123.456,789", maybe with alternate digits).
Because "it is a number".

It means the placeholders without functions are not intuitive:
"...{123456789}..." => "...123456789..."
"...{123456789 :number}..." => "...123,456.789}..."

Numeric literals are also found in options: ...{$foo :function opt1=bar opt2=baz opt3=42}..., and in decision keys.


TLDR:
We have numeric literals in syntax.
We need to know if a literal was numeric when we format to string.
But we drop that info in the data model, which sits in the middle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    LDML46.1MF2.0 Draft CandidatePreview-FeedbackFeedback gathered during the technical previewblocker-candidateThe submitter thinks this might be a block for the next releasedata modelIssues related to the Interchange Data Modelresolve-candidateThis issue appears to have been answered or resolved, and may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions