@@ -7,7 +7,7 @@ when formatting a message for display in a user interface, or for some later pro
7
7
8
8
To start, we presume that a _ message_ has either been parsed from its syntax
9
9
or created from a data model description.
10
- If this construction has encountered any Syntax or Data Model errors ,
10
+ If this construction has encountered any Syntax or Data Model Errors ,
11
11
their handling during formatting is specified here as well.
12
12
13
13
Formatting of a _ message_ is defined by the following operations:
@@ -67,7 +67,7 @@ At a minimum, it includes:
67
67
This will be used by strategies for bidirectional isolation,
68
68
and can be used to set the base direction of the _ message_ upon display.
69
69
70
- - A mapping of string identifiers to values,
70
+ - An ** _ < dfn >input mapping</ dfn > _ ** of string identifiers to values,
71
71
defining variable values that are available during _ variable resolution_ .
72
72
This is often determined by a user-provided argument of a formatting function call.
73
73
@@ -83,11 +83,15 @@ Implementations MAY include additional fields in their _formatting context_.
83
83
84
84
_ Expressions_ are used in _ declarations_ , _ selectors_ , and _ patterns_ .
85
85
86
- In a _ declaration_ , the resolved value of the _ expression_ is assigned to a _ variable_ ,
86
+ In a _ declaration_ , the resolved value of the _ expression_ is bound to a _ variable_ ,
87
87
which is available for use by later _ expressions_ .
88
88
Since a _ variable_ can be referenced in different ways later,
89
89
implementations SHOULD NOT immediately fully format the value for output.
90
90
91
+ In an _ input-declaration_ , the _ variable_ operand of the _ variable-expression_
92
+ identifies not only the name of the external input value,
93
+ but also the _ variable_ to which the resolved value of the _ variable-expression_ is bound.
94
+
91
95
In _ selectors_ , the resolved value of an _ expression_ is used for _ pattern selection_ .
92
96
93
97
In a _ pattern_ , the resolved value of an _ expression_ is used in its _ formatting_ .
@@ -106,7 +110,7 @@ and different implementations MAY choose to perform different levels of resoluti
106
110
> Alternatively, it could be an instance of an ICU4J `FormattedNumber`,
107
111
> or some other locally appropriate value.
108
112
109
- Depending on the presence or absence of an _operand_
113
+ Depending on the presence or absence of a _variable_ or _literal_ operand
110
114
and a _function_, _private-use_, or _reserved_ _annotation_,
111
115
the resolved value of the _expression_ is determined as follows:
112
116
@@ -119,8 +123,7 @@ its resolved value is defined according to the implementation's specification.
119
123
Else, if the _expression_ contains an _annotation_,
120
124
its resolved value is defined by _function resolution_.
121
125
122
- Else, the _expression_ will contain only an _operand_,
123
- which consists of either a _literal_ or a _variable_.
126
+ Else, the _expression_ will contain only either a _literal_ or a _variable_.
124
127
125
128
If the _expression_ consists of a _variable_,
126
129
its resolved value is defined by _variable resolution_.
@@ -150,9 +153,9 @@ its resolved value is defined by _literal resolution_.
150
153
> an _annotation_ needs to be provided:
151
154
>
152
155
> ```
153
- > let $aNumber = {1234 :number}
154
- > let $aDate = {|2023-08-30| :datetime}
155
- > let $aFoo = {|some foo| :foo}
156
+ > local $aNumber = {1234 :number}
157
+ > local $aDate = {|2023-08-30| :datetime}
158
+ > local $aFoo = {|some foo| :foo}
156
159
> {You have {42 :number}}
157
160
> ```
158
161
@@ -175,13 +178,10 @@ The resolution of a _text_ or _literal_ token MUST always succeed.
175
178
### Variable Resolution
176
179
177
180
To resolve the value of a _variable_,
178
- its _name_ is used to identify either a local variable,
179
- or a variable defined elsewhere.
180
- If a local variable and an externally defined one use the same name,
181
- the local variable takes precedence.
182
-
183
- It is an error for a local variable definition to
184
- refer to a local variable that's defined after it in the message.
181
+ its _name_ is used to identify either a local variable or an input variable.
182
+ If a _declaration_ exists for the _variable_, its resolved value is used.
183
+ Otherwise, the _variable_ is an implicit reference to an input value,
184
+ and its value is looked up from the _formatting context_ _input mapping_.
185
185
186
186
The resolution of a _variable_ MAY fail if no value is identified for its _name_.
187
187
If this happens, an Unresolved Variable error MUST be emitted.
@@ -272,12 +272,12 @@ rather than the _expression_ in the _selector_ or _pattern_.
272
272
> attempting to format either of the following messages:
273
273
>
274
274
> ```
275
- > let $var = {|horse| :func}
275
+ > local $var = {|horse| :func}
276
276
> {The value is {$var}.}
277
277
> ```
278
278
>
279
279
> ```
280
- > let $var = {|horse|}
280
+ > local $var = {|horse|}
281
281
> {The value is {$var :func}.}
282
282
> ```
283
283
>
@@ -690,7 +690,7 @@ These are divided into the following categories:
690
690
> ```
691
691
>
692
692
> ```
693
- > let $var = {|no message body|}
693
+ > local $var = {|no message body|}
694
694
> ```
695
695
696
696
- **Data Model errors** occur when a message is invalid due to
@@ -744,16 +744,15 @@ These are divided into the following categories:
744
744
> ```
745
745
>
746
746
> ```
747
- > let $one = {|The one|}
747
+ > local $one = {|The one|}
748
748
> match {$one}
749
749
> when 1 {Value is one}
750
750
> when * {Value is not one}
751
751
> ```
752
752
>
753
753
> ```
754
- > let $one = {|The one| :func}
755
- > let $two = {$one}
756
- > match {$two}
754
+ > input {$one}
755
+ > match {$one}
757
756
> when 1 {Value is one}
758
757
> when * {Value is not one}
759
758
> ```
@@ -769,7 +768,7 @@ These are divided into the following categories:
769
768
> ```
770
769
>
771
770
> ```
772
- > let $foo = {horse :func one=1 two=2 one=1}
771
+ > local $foo = {horse :func one=1 two=2 one=1}
773
772
> {This is {$foo}}
774
773
> ```
775
774
@@ -844,7 +843,7 @@ These are divided into the following categories:
844
843
> ```
845
844
>
846
845
> ```
847
- > let $sel = {|horse| :plural}
846
+ > local $sel = {|horse| :plural}
848
847
> match {$sel}
849
848
> when 1 {The value is one.}
850
849
> when * {The value is not one.}
@@ -873,7 +872,7 @@ These are divided into the following categories:
873
872
> ```
874
873
>
875
874
> ```
876
- > let $id = {$user :get field=id}
875
+ > local $id = {$user :get field=id}
877
876
> {Hello, {$id :get field=name}!}
878
877
> ```
879
878
>
0 commit comments