Skip to content

Commit b729d38

Browse files
eemeliaphillipscatamorphism
authored
Define function composition for :number and :integer values (#823)
* Define function composition for :number and :integer values * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> * Add operand option priority example * Add apostrophes' Co-authored-by: Tim Chevalier <[email protected]> * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> * Update spec/registry.md Co-authored-by: Eemeli Aro <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]> Co-authored-by: Tim Chevalier <[email protected]>
1 parent 662c97f commit b729d38

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

spec/registry.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ The following options and their values are required to be available on the funct
153153
- `maximumSignificantDigits`
154154
- ([digit size option](#digit-size-options))
155155
156+
If the _operand_ of the _expression_ is an implementation-defined type,
157+
such as the _resolved value_ of an _expression_ with a `:number` or `:integer` _annotation_,
158+
it can include option values.
159+
These are included in the resolved option values of the _expression_,
160+
with _options_ on the _expression_ taking priority over any option values of the _operand_.
161+
162+
> For example, the _placeholder_ in this _message_:
163+
> ```
164+
> .input {$n :number notation=scientific minimumFractionDigits=2}
165+
> {{{$n :number minimumFractionDigits=1}}}
166+
> ```
167+
> would be formatted with the resolved options
168+
> `{ notation: 'scientific', minimumFractionDigits: '1' }`.
169+
156170
> [!NOTE]
157171
> The following options and option values are being developed during the Technical Preview
158172
> period.
@@ -221,6 +235,14 @@ MUST be multiplied by 100 for the purposes of formatting.
221235
222236
The _function_ `:number` performs selection as described in [Number Selection](#number-selection) below.
223237
238+
#### Composition
239+
240+
When an _operand_ or an _option_ value uses a _variable_ annotated,
241+
directly or indirectly, by a `:number` _annotation_,
242+
its _resolved value_ contains an implementation-defined numerical value
243+
of the _operand_ of the annotated _expression_,
244+
together with the resolved options' values.
245+
224246
### The `:integer` function
225247
226248
The function `:integer` is a selector and formatter for matching or formatting numeric
@@ -230,7 +252,6 @@ values as integers.
230252
231253
The function `:integer` requires a [Number Operand](#number-operands) as its _operand_.
232254
233-
234255
#### Options
235256
236257
Some options do not have default values defined in this specification.
@@ -270,6 +291,18 @@ function `:integer`:
270291
- `maximumSignificantDigits`
271292
- ([digit size option](#digit-size-options))
272293
294+
If the _operand_ of the _expression_ is an implementation-defined type,
295+
such as the _resolved value_ of an _expression_ with a `:number` or `:integer` _annotation_,
296+
it can include option values.
297+
In general, these are included in the resolved option values of the _expression_,
298+
with _options_ on the _expression_ taking priority over any option values of the _operand_.
299+
Option values with the following names are however discarded if included in the _operand_:
300+
- `compactDisplay`
301+
- `notation`
302+
- `minimumFractionDigits`
303+
- `maximumFractionDigits`
304+
- `minimumSignificantDigits`
305+
273306
> [!NOTE]
274307
> The following options and option values are being developed during the Technical Preview
275308
> period.
@@ -338,6 +371,14 @@ MUST be multiplied by 100 for the purposes of formatting.
338371
339372
The _function_ `:integer` performs selection as described in [Number Selection](#number-selection) below.
340373
374+
#### Composition
375+
376+
When an _operand_ or an _option_ value uses a _variable_ annotated,
377+
directly or indirectly, by a `:integer` _annotation_,
378+
its _resolved value_ contains the implementation-defined integer value
379+
of the _operand_ of the annotated _expression_,
380+
together with the resolved options' values.
381+
341382
### Number Operands
342383
343384
The _operand_ of a number function is either an implementation-defined type or

0 commit comments

Comments
 (0)