Skip to content

Commit 09a8116

Browse files
eemeliaphillips
andauthored
Clarify that .match selectors are not declarations (#750)
* Clarify that .match selectors are not declarations * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent 21aec3c commit 09a8116

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

spec/formatting.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,15 @@ Earlier _selectors_ in the _matcher_'s list of _selectors_ have a higher priorit
489489
When all of the _selectors_ have been processed,
490490
the earliest-sorted _variant_ in the remaining list of _variants_ is selected.
491491
492+
> [!NOTE]
493+
> A _selector_ is not a _declaration_.
494+
> Even when the same _function_ can be used for both formatting and selection
495+
> of a given _operand_
496+
> the _annotation_ that appears in a _selector_ has no effect on subsequent
497+
> _selectors_ nor on the formatting used in _placeholders_.
498+
> To use the same value for selection and formatting,
499+
> set its value with a `.input` or `.local` _declaration_.
500+
492501
This selection method is defined in more detail below.
493502
An implementation MAY use any pattern selection method,
494503
as long as its observable behavior matches the results of the method defined here.
@@ -692,10 +701,11 @@ and an `en` (English) locale,
692701
the pattern selection proceeds as follows for this message:
693702
694703
```
695-
.match {$count :number}
696-
one {{Category match}}
697-
1 {{Exact match}}
698-
* {{Other match}}
704+
.input {$count :number}
705+
.match {$count}
706+
one {{Category match for {$count}}}
707+
1 {{Exact match for {$count}}}
708+
* {{Other match for {$count}}}
699709
```
700710
701711
1. For the selector:<br>
@@ -716,7 +726,7 @@ one {{Category match}}
716726
This is then sorted as:<br>
717727
« ( 0, `1` ), ( 1, `one` ), ( 2, `*` ) »<br>
718728
719-
4. The pattern `Exact match` of the most preferred `1` variant is selected.
729+
4. The pattern `Exact match for {$count}` of the most preferred `1` variant is selected.
720730
721731
## Formatting
722732

spec/syntax.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ match-statement = match 1*([s] selector)
369369
> A _message_ with a _matcher_:
370370
>
371371
> ```
372-
> .match {$count :number}
372+
> .input {$count :number}
373+
> .match {$count}
373374
> one {{You have {$count} notification.}}
374375
> * {{You have {$count} notifications.}}
375376
> ```
@@ -408,7 +409,9 @@ There MAY be any number of additional _selectors_.
408409
> A message with two _selectors_:
409410
>
410411
> ```
411-
> .match {$numLikes :number} {$numShares :number}
412+
> .input {$numLikes :integer}
413+
> .input {$numShares :integer}
414+
> .match {$numLikes} {$numShares}
412415
> 0 0 {{Your item has no likes and has not been shared.}}
413416
> 0 one {{Your item has no likes and has been shared {$numShares} time.}}
414417
> 0 * {{Your item has no likes and has been shared {$numShares} times.}}

0 commit comments

Comments
 (0)