Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide structure in the registry for distinguishing types of options #663

Open
macchiati opened this issue Feb 18, 2024 · 6 comments
Open
Labels
normative registry resolve-candidate This issue appears to have been answered or resolved, and may be closed soon. specification

Comments

@macchiati
Copy link
Member

macchiati commented Feb 18, 2024

I think in the registry we need to be very clear about the following classes of effects that an option can have. (Of course, an option may do more than one of these)

  • an option effectively supplies input in addition to the operand (eg, timezone, currency, ...)
  • an option that modifies the formatting of the operand (eg, mix/max fractional digits)
  • an option that modifies the selection of an operand (eg, also mix/max fractional digits)

We'll also have functions that transform the underlying value of an operand (we don't have any right now, but we will absolutely need that for offsets in order to support a core MF1.0 feature).

@aphillips
Copy link
Member

I don't understand your use of the term "operand" here. In our syntax, the term "operand" means the argument to a function:

{$operand :function option=value}

Do you mean "option"?

@macchiati
Copy link
Member Author

Whoops, I'll fix that.

@eemeli eemeli changed the title Provide structure in the registry for distinguishing types of operands Provide structure in the registry for distinguishing types of options Feb 19, 2024
@eemeli
Copy link
Collaborator

eemeli commented Feb 19, 2024

You know, we could also consider separating out options that really are adding to the function's nominal input operand to also be operands. As in, allow for function expressions with more than one operand, such as:

Your purchases add up to {$sum $currency :number style=currency}

A marathon is {42.195 kilometer :number style=unit} long.

It is currently {$time |America/Chicago| :time} in Chicago.

The ABNF change for this would be relatively limited, with something like

value-expression = "{" [s]
                   (literal | variable)
                   [*(s literal | variable) s annotation]
                   *(s attribute)
                   [s] "}"

replacing the current literal-expression and variable-expression.

@aphillips
Copy link
Member

We could do that, but I think that goes against authoring simplicity as I no longer know what variable is being inserted.

In the case of the compound units, primary reason for "multiple operands" is the need to serialize the compound unit in some way. If one has values 2...n, then one can as easily assign them to options as to operands. And this keeps us out of the "find and match the argument" problem:

Your purchases add up to {$currency $sum :number style=currency}

A marathon is {kilometer 42.195 :number style=unit} long.

It is currently {|America/Chicago| $time :time} in Chicago.

You have a {|froot-loop| wildebeest extravaganza :string}.

Otherwise, I'm sure that (for example) Mihai will implement :number so that (in ICU4J) passing a com.ibm.icu.util.CurrencyAmount formats the getNumber() amount using the option currency set to getCurrency().getCurrencyCode() and, if not overridden by a style option, sets style=currency to boot.

@catamorphism
Copy link
Collaborator

For clarity, I would suggest not using the word "effects", since MF functions don't have effects that are observable across different calls (or rather, if they do, that's not behavior the spec can depend on.)

That being said, this would be helpful for addressing #515 . You could think of this as a "data model" for runtime values, not just for messages.

@aphillips aphillips added the resolve-candidate This issue appears to have been answered or resolved, and may be closed soon. label Nov 9, 2024
@aphillips
Copy link
Member

I think this item might now be stale, with the resolved value work that's been done. Marking to consider for closure in the 2024-11-11 call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
normative registry resolve-candidate This issue appears to have been answered or resolved, and may be closed soon. specification
Projects
None yet
Development

No branches or pull requests

4 participants