From 7e43bb5ffa632e2b17754c87fa28b8ce6403c6b7 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 19 Mar 2024 12:55:37 -0700 Subject: [PATCH 1/9] Define non-negative integer option @catamorphism identified this as a gap in e.g. #739. This PR defines what a non-negative integer option value is for `:number` and `:integer`. It does not attempt to address the larger question raised in 738/739. --- spec/registry.md | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 22066ec34e..21d674100f 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -398,15 +398,15 @@ The following options and their values are required to be available on the funct - `never` - `min2` - `minimumIntegerDigits` - - (non-negative integer, default: `1`) + - ([non-negative integer](#non-negative-integer-options), default: `1`) - `minimumFractionDigits` - - (non-negative integer) + - ([non-negative integer](#non-negative-integer-options)) - `maximumFractionDigits` - - (non-negative integer) + - ([non-negative integer](#non-negative-integer-options)) - `minimumSignificantDigits` - - (non-negative integer) + - ([non-negative integer](#non-negative-integer-options)) - `maximumSignificantDigits` - - (non-negative integer) + - ([non-negative integer](#non-negative-integer-options)) > [!NOTE] > The following options and option values are being developed during the Technical Preview @@ -515,9 +515,9 @@ function `:integer`: - `always` - `min2` - `minimumIntegerDigits` - - (non-negative integer, default: `1`) + - ([non-negative integer](#non-negative-integer-options), default: `1`) - `maximumSignificantDigits` - - (non-negative integer) + - ([non-negative integer](#non-negative-integer-options)) > [!NOTE] > The following options and option values are being developed during the Technical Preview @@ -619,7 +619,17 @@ All other values produce an _Invalid Expression_ error. > or the type `com.ibm.icu.util.CurrencyAmount` can be used to set the currency and related > options (such as the number of fraction digits). +### Non-Negative Integer Options +Some _options_ of number _functions_ are defined to take a "non-negative integer". +In most cases, these control the number of various kinds of digits. + +A "non-negative integer" is one of: +- an implementation-defined integer numeric type where the value of the + encoded number is not less than zero +- a literal consisting only of ASCII digits U+0030 through U+0039; + An implementation MAY define an upper limit on the length of such a literal + or of the value encoded by such a literal. ### Number Selection From 044ed7821616d93e939afcb0795a914c063347e9 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 19 Mar 2024 16:45:26 -0700 Subject: [PATCH 2/9] Address @eemelie's comment ... via a rewrite. Adds an example. Permits upper length limit. Removes any mention of types. Permits an upper numeric amount (e.g. if you're implementation of number formatting is limited to, say, 64 digits, you can make the maximum allowed value `64`) --- spec/registry.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 21d674100f..acfa778ff3 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -624,12 +624,21 @@ All other values produce an _Invalid Expression_ error. Some _options_ of number _functions_ are defined to take a "non-negative integer". In most cases, these control the number of various kinds of digits. -A "non-negative integer" is one of: -- an implementation-defined integer numeric type where the value of the - encoded number is not less than zero -- a literal consisting only of ASCII digits U+0030 through U+0039; - An implementation MAY define an upper limit on the length of such a literal - or of the value encoded by such a literal. +A "non-negative integer" is a variable reference or literal whose value evaluates +as an integer greater than or equal to zero. +If the value is passed as a literal +it MUST contain only the ASCII digits U+0030 through U+0039. +Implementations MAY define an upper limit on the length of such a literal. +Implementations MAY define an upper limit on the resolved value +of a non-negative integer option consistent with that implementation's practical limits. + +> **Examples of literal non-negative integer options** +> ``` +> {$n :number maximumFractionDigits=12} +> {$n :number maximumFractionDigits=|12|} +> {$n :number maximumFractionDigits=123456} +> {$n :number maximumFractionDigits=|0123|} +> ``` ### Number Selection From f9bd83101acd8ac1e81f74c25101e84926b33565 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Tue, 19 Mar 2024 16:50:20 -0700 Subject: [PATCH 3/9] Update spec/registry.md --- spec/registry.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/registry.md b/spec/registry.md index acfa778ff3..15ee8e7727 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -622,7 +622,8 @@ All other values produce an _Invalid Expression_ error. ### Non-Negative Integer Options Some _options_ of number _functions_ are defined to take a "non-negative integer". -In most cases, these control the number of various kinds of digits. +In this specification, these _options_ are used to control aspects of numeric display +such as the number of fraction, integer, or significant digits. A "non-negative integer" is a variable reference or literal whose value evaluates as an integer greater than or equal to zero. From af10060cec7aef6cd7b1f04ce96842686e031dcd Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Wed, 20 Mar 2024 08:45:50 -0700 Subject: [PATCH 4/9] Address comments --- spec/registry.md | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 15ee8e7727..0ad78e29aa 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -622,24 +622,40 @@ All other values produce an _Invalid Expression_ error. ### Non-Negative Integer Options Some _options_ of number _functions_ are defined to take a "non-negative integer". -In this specification, these _options_ are used to control aspects of numeric display +Implementations of number _functions_ use these _options_ to control aspects of numeric display such as the number of fraction, integer, or significant digits. -A "non-negative integer" is a variable reference or literal whose value evaluates -as an integer greater than or equal to zero. -If the value is passed as a literal -it MUST contain only the ASCII digits U+0030 through U+0039. -Implementations MAY define an upper limit on the length of such a literal. +A "non-negative integer" is an _option_ value that the _function_ evaluates as an integer +greater than or equal to zero. Implementations MAY define an upper limit on the resolved value of a non-negative integer option consistent with that implementation's practical limits. -> **Examples of literal non-negative integer options** +The implementation MAY accept any implementation-defined type as the value. +Implementations MUST accept the value as a _literal_. +When the value is a _literal_, +it MUST consist of a sequence of ASCII digits in the range U+0030 through U+0039. + +> **Examples of non-negative integer options** +> +> Here are some examples of valid literals: > ``` > {$n :number maximumFractionDigits=12} > {$n :number maximumFractionDigits=|12|} > {$n :number maximumFractionDigits=123456} > {$n :number maximumFractionDigits=|0123|} > ``` +> Note that the value can be passed as an input variable or defined via a declaration. +> For example, the following _messages_ might be valid in an implementation that +> accepted the type `int` and the variable `min` were passed as input: +> ``` +> .local $max = {1 :integer} +> {{You have {$n :number maximumFractionDigits=$max}}} +> +> {{{$n :number minimumFractionDigits=$min} where 'min' is an 'int' >= 0}} +> +> .local $max = {|2|} +> {{{$n :number maximumFractionDigits=$max} where 'max' is a literal}} +> ``` ### Number Selection From f002e44eb05f566df28c7502c271e11f95399ac7 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Wed, 20 Mar 2024 16:18:16 -0700 Subject: [PATCH 5/9] Update spec/registry.md --- spec/registry.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 0ad78e29aa..ce6ac28441 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -632,8 +632,10 @@ of a non-negative integer option consistent with that implementation's practical The implementation MAY accept any implementation-defined type as the value. Implementations MUST accept the value as a _literal_. -When the value is a _literal_, -it MUST consist of a sequence of ASCII digits in the range U+0030 through U+0039. +When the value is a _literal_, it MUST match `non-negative` in this ABNF: +>```abnf +>non-negative = "0" / (("1"-"9") *DIGIT) +>``` > **Examples of non-negative integer options** > From b23aaec68e539224a4d458bd72c8b1388d9570af Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Wed, 20 Mar 2024 16:18:25 -0700 Subject: [PATCH 6/9] Update spec/registry.md Co-authored-by: Eemeli Aro --- spec/registry.md | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index ce6ac28441..1bed7603e4 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -637,27 +637,6 @@ When the value is a _literal_, it MUST match `non-negative` in this ABNF: >non-negative = "0" / (("1"-"9") *DIGIT) >``` -> **Examples of non-negative integer options** -> -> Here are some examples of valid literals: -> ``` -> {$n :number maximumFractionDigits=12} -> {$n :number maximumFractionDigits=|12|} -> {$n :number maximumFractionDigits=123456} -> {$n :number maximumFractionDigits=|0123|} -> ``` -> Note that the value can be passed as an input variable or defined via a declaration. -> For example, the following _messages_ might be valid in an implementation that -> accepted the type `int` and the variable `min` were passed as input: -> ``` -> .local $max = {1 :integer} -> {{You have {$n :number maximumFractionDigits=$max}}} -> -> {{{$n :number minimumFractionDigits=$min} where 'min' is an 'int' >= 0}} -> -> .local $max = {|2|} -> {{{$n :number maximumFractionDigits=$max} where 'max' is a literal}} -> ``` ### Number Selection From 94db1cb228d9c472693c9419c92e5b1a1da2f821 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Fri, 22 Mar 2024 06:44:31 -0700 Subject: [PATCH 7/9] Update spec/registry.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Stanisław Małolepszy --- spec/registry.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/registry.md b/spec/registry.md index 1bed7603e4..21ecf564ff 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -631,7 +631,7 @@ Implementations MAY define an upper limit on the resolved value of a non-negative integer option consistent with that implementation's practical limits. The implementation MAY accept any implementation-defined type as the value. -Implementations MUST accept the value as a _literal_. +Implementations MUST accept a _literal_ as the value. When the value is a _literal_, it MUST match `non-negative` in this ABNF: >```abnf >non-negative = "0" / (("1"-"9") *DIGIT) From 632f6a67dccb8ede46048be91bfbcb1b98ea305e Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Mon, 25 Mar 2024 14:01:11 -0700 Subject: [PATCH 8/9] Implement changes discussed in 2024-03-25 call --- spec/registry.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index 21ecf564ff..e06d07eff5 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -398,15 +398,15 @@ The following options and their values are required to be available on the funct - `never` - `min2` - `minimumIntegerDigits` - - ([non-negative integer](#non-negative-integer-options), default: `1`) + - ([digit size option](#digit-size-options), default: `1`) - `minimumFractionDigits` - - ([non-negative integer](#non-negative-integer-options)) + - ([digit size option](#digit-size-options)) - `maximumFractionDigits` - - ([non-negative integer](#non-negative-integer-options)) + - ([digit size option](#digit-size-options)) - `minimumSignificantDigits` - - ([non-negative integer](#non-negative-integer-options)) + - ([digit size option](#digit-size-options)) - `maximumSignificantDigits` - - ([non-negative integer](#non-negative-integer-options)) + - ([digit size option](#digit-size-options)) > [!NOTE] > The following options and option values are being developed during the Technical Preview @@ -515,9 +515,9 @@ function `:integer`: - `always` - `min2` - `minimumIntegerDigits` - - ([non-negative integer](#non-negative-integer-options), default: `1`) + - ([digit size option](#digit-size-options), default: `1`) - `maximumSignificantDigits` - - ([non-negative integer](#non-negative-integer-options)) + - ([digit size option](#digit-size-options)) > [!NOTE] > The following options and option values are being developed during the Technical Preview @@ -619,22 +619,23 @@ All other values produce an _Invalid Expression_ error. > or the type `com.ibm.icu.util.CurrencyAmount` can be used to set the currency and related > options (such as the number of fraction digits). -### Non-Negative Integer Options +### Digit Size Options -Some _options_ of number _functions_ are defined to take a "non-negative integer". +Some _options_ of number _functions_ are defined to take a "digit size option". Implementations of number _functions_ use these _options_ to control aspects of numeric display such as the number of fraction, integer, or significant digits. -A "non-negative integer" is an _option_ value that the _function_ evaluates as an integer -greater than or equal to zero. +A "digit size option" is an _option_ value that the _function_ interprets +as a small integer value greater than or equal to zero. Implementations MAY define an upper limit on the resolved value -of a non-negative integer option consistent with that implementation's practical limits. +of a digit size option option consistent with that implementation's practical limits. -The implementation MAY accept any implementation-defined type as the value. -Implementations MUST accept a _literal_ as the value. -When the value is a _literal_, it MUST match `non-negative` in this ABNF: +In most cases, the value of a digit size option will be a string literal that +encodes the value as a decimal integer. +Implementations MAY also accept implementation-defined types as the value. +The _literal_ representation of a digit size option matches the following ABNF: >```abnf ->non-negative = "0" / (("1"-"9") *DIGIT) +> digit-size-option = "0" / (("1"-"9") [DIGIT]) >``` From dd6cada49adb6b492d72cfa453d1cc35d07bca67 Mon Sep 17 00:00:00 2001 From: Addison Phillips Date: Mon, 25 Mar 2024 14:42:13 -0700 Subject: [PATCH 9/9] Address comments --- spec/registry.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/registry.md b/spec/registry.md index e06d07eff5..12cd6eb44b 100644 --- a/spec/registry.md +++ b/spec/registry.md @@ -630,10 +630,10 @@ as a small integer value greater than or equal to zero. Implementations MAY define an upper limit on the resolved value of a digit size option option consistent with that implementation's practical limits. -In most cases, the value of a digit size option will be a string literal that +In most cases, the value of a digit size option will be a string that encodes the value as a decimal integer. Implementations MAY also accept implementation-defined types as the value. -The _literal_ representation of a digit size option matches the following ABNF: +When provided as a string, the representation of a digit size option matches the following ABNF: >```abnf > digit-size-option = "0" / (("1"-"9") [DIGIT]) >```