Skip to content

Define non-negative integer option #741

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

Merged
merged 9 commits into from
Mar 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 25 additions & 7 deletions spec/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
- ([digit size option](#digit-size-options), default: `1`)
- `minimumFractionDigits`
- (non-negative integer)
- ([digit size option](#digit-size-options))
- `maximumFractionDigits`
- (non-negative integer)
- ([digit size option](#digit-size-options))
- `minimumSignificantDigits`
- (non-negative integer)
- ([digit size option](#digit-size-options))
- `maximumSignificantDigits`
- (non-negative integer)
- ([digit size option](#digit-size-options))

> [!NOTE]
> The following options and option values are being developed during the Technical Preview
Expand Down Expand Up @@ -515,9 +515,9 @@ function `:integer`:
- `always`
- `min2`
- `minimumIntegerDigits`
- (non-negative integer, default: `1`)
- ([digit size option](#digit-size-options), default: `1`)
- `maximumSignificantDigits`
- (non-negative integer)
- ([digit size option](#digit-size-options))

> [!NOTE]
> The following options and option values are being developed during the Technical Preview
Expand Down Expand Up @@ -619,6 +619,24 @@ 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).

### Digit Size Options

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 "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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to say anything about what implementations should do about the lower bound?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The lower bound is always zero.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, yes :) But it seems like we don't say anything about what should happen when the passed value is, in fact, negative? Should functions emit an error? Perhaps we need a sister error to the Operand Mismatch Error, but for invalid options?

Should I file a separate issue about this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalid Option suggests itself as a sub-species of Invalid Expression.

A negative number won't parse correctly about the same way that the string moo or the string $57% does not parse as a non-negative integer. FWIW, 1,234 does not parse according to the rules laid out here nor does 11.0

The reason for upper bounds, of course, is overflow prevention.

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 that
encodes the value as a decimal integer.
Implementations MAY also accept implementation-defined types as the value.
When provided as a string, the representation of a digit size option matches the following ABNF:
>```abnf
> digit-size-option = "0" / (("1"-"9") [DIGIT])
>```


### Number Selection
Expand Down