Skip to content

Commit 6b27f32

Browse files
authored
Update examples to match changes to syntax
Also responds to the long discussion with @eemeli about significant digits by removing from the example.
1 parent 8f57d63 commit 6b27f32

File tree

1 file changed

+30
-21
lines changed

1 file changed

+30
-21
lines changed

exploration/number-selection.md

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,29 @@ As a user, I want to write messages that mix exact matching and
8383
either plural or ordinal selection in a single message.
8484
> For example:
8585
>```
86-
>.match {$numRemaining}
87-
>0 {{You have no more chances remaining (exact match)}}
88-
>1 {{You have one more chance remaining (exact match)}}
86+
>.match $numRemaining
87+
>0 {{You have no more chances remaining (exact match)}}
88+
>1 {{You have one more chance remaining (exact match)}}
8989
>one {{You have {$numRemaining} chance remaining (plural)}}
90-
> * {{You have {$numRemaining} chances remaining (plural)}}
90+
>* {{You have {$numRemaining} chances remaining (plural)}}
9191
>```
9292
9393
As a user, I want the selector to match the options specified:
9494
```
95-
.local $num = {123.456 :number maximumSignificantDigits=2 maximumFractionDigits=2 minimumFractionDigits=2}
96-
.match {$num}
97-
120.00 {{This matches}}
98-
120 {{This does not match}}
99-
123.47 {{This does not match}}
100-
123.456 {{This does not match}}
101-
1.2E2 {{Does this match?}}
102-
* {{ ... }}
95+
.local $num = {123.123 :number maximumFractionDigits=2 minimumFractionDigits=2}
96+
.match $num
97+
123.12 {{This matches}}
98+
120 {{This does not match}}
99+
123.123 {{This does not match}}
100+
1.23123E2 {{Does this match?}}
101+
* {{ ... }}
103102
```
104103
105104
Note that badly written keys just don't match, but we want users to be able to intuit whether a given set of keys will work or not.
106105
107106
```
108107
.local $num = {123.456 :integer}
109-
.match {$num}
108+
.match $num
110109
123.456 {{Should not match?}}
111110
123 {{Should match}}
112111
123.0 {{Should not match?}}
@@ -117,7 +116,7 @@ There can be complications, which we might need to define. Consider:
117116
118117
```
119118
.local $num = {123.002 :number maximumFractionDigits=1 minimumFractionDigits=0}
120-
.match {$num}
119+
.match $num
121120
123.002 {{Should not match?}}
122121
123.0 {{Does minimumFractionDigits make this not match?}}
123122
123 {{Does minimumFractionDigits make this match?}}
@@ -131,10 +130,11 @@ Implementations might also apply options by modifying the number value of the _o
131130
(or shadowing the options effect on the value)
132131
133132
As a user, I want to be able to perform exact match using arbitrary digit numeric types where they are available.
133+
134134
As an implementer, I do **not** want to be required to provide or implement arbitrary precision
135135
numeric types not available in my platform.
136136
Programming/runtime environments vary widely in support of these types.
137-
MF2 should not prevent the implementation of e.g. `BigDecimal` or `BigInt` types
137+
MF2 should not prevent the implementation using, for example, `BigDecimal` or `BigInt` types
138138
and permit their use in MF2 messages.
139139
MF2 should not _require_ implementations to support such types where they do not exist.
140140
The problem of numeric type precision,
@@ -144,7 +144,7 @@ should not affect how message `key` values are specified.
144144
> For example:
145145
>```
146146
>.local $num = {11111111111111.11111111111111 :number}
147-
>.match {$num}
147+
>.match $num
148148
>11111111111111.11111111111111 {{This works on some implementations.}}
149149
>* {{... but not on others? ...}}
150150
>```
@@ -351,7 +351,8 @@ but can cause problems in target locales that the original developer is not cons
351351
> considering other locale's need for a `one` plural:
352352
>
353353
> ```
354-
> .match {$var}
354+
> .input {$var :integer}
355+
> .match $var
355356
> 1 {{You have one last chance}}
356357
> one {{You have {$var} chance remaining}} // needed by languages such as Polish or Russian
357358
> // such locales typically require other keywords
@@ -365,6 +366,12 @@ but can cause problems in target locales that the original developer is not cons
365366
When implementing `style=percent`, the numeric value of the operand
366367
MUST be divided by 100 for the purposes of formatting.
367368
369+
> For example,
370+
> ```
371+
> .local $percent = {1000 :integer style=percent}
372+
> {{This formats as '10%' in the en-US locale: {$percent}}}
373+
> ```
374+
368375
### Selection
369376
370377
When implementing [`MatchSelectorKeys`](spec/formatting.md#resolve-preferences),
@@ -489,7 +496,9 @@ To expand on the last of these,
489496
consider this message:
490497
491498
```
492-
.match {$count :plural minimumFractionDigits=1}
499+
.input {$count :number minimumFractionDigits=1}
500+
.local $selector = {$count :plural}
501+
.match $selector
493502
0 {{You have no apples}}
494503
1 {{You have exactly one apple}}
495504
* {{You have {$count :number minimumFractionDigits=1} apples}}
@@ -504,9 +513,9 @@ With the proposed design, this message would much more naturally be written as:
504513
505514
```
506515
.input {$count :number minimumFractionDigits=1}
507-
.match {$count}
508-
0 {{You have no apples}}
509-
1 {{You have exactly one apple}}
516+
.match $count
517+
0.0 {{You have no apples}}
518+
1.0 {{You have exactly one apple}}
510519
one {{You have {$count} apple}}
511520
* {{You have {$count} apples}}
512521
```

0 commit comments

Comments
 (0)