Skip to content

Commit a286c85

Browse files
authored
(Design) Exact Match Selector Options
In response to #433 we need to choose a name for the "exact match" selector. This isn't done yet but will serve as a foundation for choosing.
1 parent 50830a8 commit a286c85

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
# Design Proposal Template
2+
3+
Status: **Proposed**
4+
5+
<details>
6+
<summary>Metadata</summary>
7+
<dl>
8+
<dt>Contributors</dt>
9+
<dd>@aphillips</dd>
10+
<dt>First proposed</dt>
11+
<dd>2023-12-08</dd>
12+
</dl>
13+
</details>
14+
15+
## Objective
16+
17+
_What is this proposal trying to achieve?_
18+
19+
We need to choose a name for the default "exact match" selector function.
20+
21+
## Background
22+
23+
_What context is helpful to understand this proposal?_
24+
25+
This addresses issue <a href="https://github.com/unicode-org/message-format-wg/issues/433">#433</a>
26+
and issues raised in various design documents, notably
27+
<a href="https://github.com/unicode-org/message-format-wg/pull/471">#471</a>
28+
(about number selection).
29+
30+
The default selector function is the function used when an implementation
31+
cannot find another selector.
32+
It is also an attribute of selectors, such as `:number` or perhaps `:date`
33+
that need to match specific values.
34+
ICU MF1 has a selector called `com.ibm.icu.text.SelectFormat`
35+
associated with the keyword `select` in the MF1 syntax.
36+
37+
## Use-Cases
38+
39+
_What use-cases do we see? Ideally, quote concrete examples._
40+
41+
As a developer, I would like to create matches based on arbitrary enumerated string
42+
values in a manner similar to ICU MF1's `SelectFormat`.
43+
This allows me to use an ordinary enum or data values already present in my data
44+
to do pattern selection.
45+
46+
As a user, I would like to create numeric matches based on a specific value
47+
not just the plural or ordinal category of the value.
48+
This is for cases where the pattern selected is tied to the actual value
49+
rather than just to the grammatical needs of the language.
50+
Consider the different between the messages in:
51+
>```
52+
>.match {$numChances :number}
53+
>1 {{You have one chance left}}
54+
>one {{You have {$numChances}} chance left}}
55+
>* {{You have {$numChances}} chances left}}
56+
>```
57+
58+
As an implementer, I want to create value matches that are not strictly
59+
tied to the string serialization for data types that I know.
60+
> For example, if a date value were serialized as
61+
> `2023-12-08T12:00:00Z[America/Los_Angeles]` and the selector were
62+
> `{$myDate :date dateStyle=long}` **_and_** I want to do select on the
63+
> date value, I might want a match like this:
64+
>```
65+
>.match {$myDate}
66+
>2023-12-08 {{This only fires on this specific date}}
67+
>* {{This fires some other time}}
68+
>```
69+
>A different example that makes this clearer might be numbers.
70+
> In the `de-DE` locale, the number `42.3` is usually formatted
71+
> as `42,3`. Consider the message:
72+
> ```
73+
> .local $myNum = {|42.3| :number minFractionDigits=1}
74+
> .match {$myNum :equals}
75+
> 42.3 {{This always matches}
76+
> * {{This never matches}}
77+
> ```
78+
79+
As a user, I want to use a selector name that makes sense and feels natural to write.
80+
81+
## Requirements
82+
83+
_What properties does the solution have to manifest to enable the use-cases above?_
84+
85+
## Constraints
86+
87+
_What prior decisions and existing conditions limit the possible design?_
88+
89+
## Proposed Design
90+
91+
_Describe the proposed solution. Consider syntax, formatting, errors, registry, tooling, interchange._
92+
93+
## Alternatives Considered
94+
95+
_What other solutions are available?_
96+
_How do they compare against the requirements?_
97+
_What other properties do they have?_
98+
99+
### Option A. `:select`
100+
101+
Pros:
102+
- The same as ICU MF1's keyword. We have implementation experience.
103+
104+
Cons:
105+
- Somewhat generic name.
106+
107+
### Option B. `:exact`
108+
109+
Pros:
110+
- Says what the match does.
111+
112+
Cons:
113+
- Not super specific?
114+
115+
### Option C. `:equals`
116+
117+
Pros:
118+
- Says what the match does.
119+
120+
Cons:
121+
- Implies object or value equality, which may not be correct in all implementations
122+
or programming languages.
123+
The implications might be confusing to users in those cases.
124+
125+
### Option D. `:string`
126+
127+
Pros:
128+
- Clearer about what is being compared than `select` or `exact`:
129+
it's the string value?
130+
131+
Cons:
132+
- Not clear about
133+
134+
### Option E. Something else
135+
136+
It is possible that we haven't landed the best name yet.
137+
If you don't like any of these, what **_do_** you like?!?

0 commit comments

Comments
 (0)