-
-
Notifications
You must be signed in to change notification settings - Fork 36
Change :math
to :offset
and remove draft status
#1073
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -159,40 +159,41 @@ together with the resolved options' values. | |||||||
|
||||||||
The _function_ `:integer` performs selection as described in [Number Selection](#number-selection) below. | ||||||||
|
||||||||
#### The `:math` function | ||||||||
#### The `:offset` function | ||||||||
|
||||||||
> [!IMPORTANT] | ||||||||
> The _function_ `:math` has a status of **Draft**. | ||||||||
> It is proposed for inclusion in a future release of this specification and is not Stable. | ||||||||
|
||||||||
The _function_ `:math` is proposed as a _selector_ and _formatter_ for matching or formatting | ||||||||
numeric values to which a mathematical operation has been applied. | ||||||||
The _function_ `:offset` is a _selector_ and _formatter_ for matching or formatting | ||||||||
numeric values to which an offset has been applied. | ||||||||
The "offset" is a small integer adjustment of the _operand_'s value. | ||||||||
|
||||||||
> This function is useful for selection and formatting of values that | ||||||||
> differ from the input value by a specified amount. | ||||||||
> For example, it can be used in a message such as this: | ||||||||
> For example, it can be used in a _message_ such as this: | ||||||||
> | ||||||||
> ``` | ||||||||
> .input {$like_count :integer} | ||||||||
> .local $others_count = {$like_count :math subtract=1} | ||||||||
> .local $others_count = {$like_count :offset subtract=1} | ||||||||
> .match $like_count $others_count | ||||||||
> 0 * {{Your post has no likes.}} | ||||||||
> 1 * {{{$name} liked your post.}} | ||||||||
> * one {{{$name} and {$others_count} other user liked your post.}} | ||||||||
> * * {{{$name} and {$others_count} other users liked your post.}} | ||||||||
> ``` | ||||||||
|
||||||||
##### Operands | ||||||||
> [!NOTE] | ||||||||
> The purpose of this _function_ is to supply compatibility with | ||||||||
> ICU's `PluralFormat` and its `offset` feature, also found in ICU MessageFormat. | ||||||||
|
||||||||
The function `:math` requires a [Number Operand](#number-operands) as its _operand_. | ||||||||
##### `:offset` Operands | ||||||||
|
||||||||
##### Options | ||||||||
The function `:offset` requires a [Number Operand](#number-operands) as its _operand_. | ||||||||
|
||||||||
##### `:offset` Options | ||||||||
|
||||||||
The _options_ on `:math` are exclusive with each other, | ||||||||
The _options_ on `:offset` are exclusive with each other, | ||||||||
and exactly one _option_ is always required. | ||||||||
The _options_ do not have default values. | ||||||||
Comment on lines
+192
to
194
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Delete, there is only one, and it is required below. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But this PR is not changing the inclusion of both |
||||||||
|
||||||||
The following _options_ are REQUIRED to be available on the function `:math`: | ||||||||
The following _options_ are REQUIRED to be available on the function `:offset`: | ||||||||
|
||||||||
- `add` | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's actually a subtract, since it is the remaining count. |
||||||||
- _digit size option_ | ||||||||
|
@@ -204,9 +205,9 @@ or if an _option value_ is not a _digit size option_, | |||||||
a _Bad Option_ error is emitted | ||||||||
and a _fallback value_ used as the _resolved value_ of the _expression_. | ||||||||
|
||||||||
##### Resolved Value | ||||||||
##### `:offset` Resolved Value | ||||||||
|
||||||||
The _resolved value_ of an _expression_ with a `:math` _function_ | ||||||||
The _resolved value_ of an _expression_ with a `:offset` _function_ | ||||||||
contains the implementation-defined numeric value | ||||||||
of the _operand_ of the annotated _expression_. | ||||||||
|
||||||||
|
@@ -222,18 +223,18 @@ If the _operand_ of the _expression_ is an implementation-defined numeric type, | |||||||
such as the _resolved value_ of an _expression_ with a `:number` or `:integer` _annotation_, | ||||||||
it can include option values. | ||||||||
These are included in the resolved option values of the _expression_. | ||||||||
The `:math` _options_ are not included in the resolved option values. | ||||||||
The `:offset` _options_ are not included in the resolved option values. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At least two reasons:
|
||||||||
|
||||||||
> [!NOTE] | ||||||||
> Implementations can encounter practical limits with `:math` _expressions_, | ||||||||
> Implementations can encounter practical limits with `:offset` _expressions_, | ||||||||
> such as the result of adding two integers exceeding | ||||||||
> the storage or precision of some implementation-defined number type. | ||||||||
> In such cases, implementations can emit an _Unsupported Operation_ error | ||||||||
> or they might just silently overflow the underlying data value. | ||||||||
|
||||||||
##### Selection | ||||||||
##### `:offset` Selection | ||||||||
|
||||||||
The _function_ `:math` performs selection as described in [Number Selection](#number-selection) below. | ||||||||
The _function_ `:offset` performs selection as described in [Number Selection](#number-selection) below. | ||||||||
|
||||||||
#### The `:currency` function | ||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're inverting things a bit here. As I see it, the primary purpose of this function is the same as that of plural offset in MF1, to enable the expression of messages with plural variance that depends on an offset count. Supporting migration from MF1 arises from that; it ought not be presented as "the purpose" of the function as a whole.