Skip to content

Commit f469d0d

Browse files
eemeliaphillips
andauthored
Add namespaces to example non-default functions (#971)
* Add namespaces to example non-default functions * Apply suggestions from code review Co-authored-by: Addison Phillips <[email protected]> --------- Co-authored-by: Addison Phillips <[email protected]>
1 parent 7c1f1a4 commit f469d0d

File tree

3 files changed

+46
-45
lines changed

3 files changed

+46
-45
lines changed

spec/errors.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ does not equal the number of _selectors_.
8686
> Example invalid messages resulting in a _Variant Key Mismatch_ error:
8787
>
8888
> ```
89-
> .input {$one :func}
89+
> .input {$one :ns:func}
9090
> .match $one
9191
> 1 2 {{Too many}}
9292
> * {{Otherwise}}
9393
> ```
9494
>
9595
> ```
96-
> .input {$one :func}
97-
> .input {$two :func}
96+
> .input {$one :ns:func}
97+
> .input {$two :ns:func}
9898
> .match $one $two
9999
> 1 2 {{Two keys}}
100100
> * {{Missing a key}}
@@ -109,15 +109,15 @@ does not include a _variant_ with only catch-all keys.
109109
> Example invalid messages resulting in a _Missing Fallback Variant_ error:
110110
>
111111
> ```
112-
> .input {$one :func}
112+
> .input {$one :ns:func}
113113
> .match $one
114114
> 1 {{Value is one}}
115115
> 2 {{Value is two}}
116116
> ```
117117
>
118118
> ```
119-
> .input {$one :func}
120-
> .input {$two :func}
119+
> .input {$one :ns:func}
120+
> .input {$two :ns:func}
121121
> .match $one $two
122122
> 1 * {{First is one}}
123123
> * 1 {{Second is one}}
@@ -176,9 +176,9 @@ so explicitly declaring it after such use is also an error.
176176
> .input {$var2 :number}
177177
> {{Redeclaration of the implicit input variable $var2}}
178178
>
179-
> .local $var = {$ext :someFunction}
179+
> .local $var = {$ext :ns:func}
180180
> .local $var = {$error}
181-
> .local $var2 = {$var2 :error}
181+
> .local $var2 = {$var2 :ns:error}
182182
> {{{$var} cannot be redefined. {$var2} cannot refer to itself}}
183183
> ```
184184
@@ -194,7 +194,7 @@ appears on the left-hand side of more than one _option_ in the same _expression_
194194
> ```
195195
>
196196
> ```
197-
> .local $foo = {horse :func one=1 two=2 one=1}
197+
> .local $foo = {horse :ns:func one=1 two=2 one=1}
198198
> {{This is {$foo}}}
199199
> ```
200200
@@ -240,7 +240,7 @@ An **_<dfn>Unresolved Variable</dfn>_** error occurs when a variable reference c
240240
> ```
241241
>
242242
> ```
243-
> .input {$var :func}
243+
> .input {$var :ns:func}
244244
> .match $var
245245
> 1 {{The value is one.}}
246246
> * {{The value is not one.}}
@@ -253,14 +253,14 @@ a reference to a function which cannot be resolved.
253253
254254
> For example, attempting to format either of the following messages
255255
> would result in an _Unknown Function_ error if done within a context that
256-
> does not provide for the function `:func` to be successfully resolved:
256+
> does not provide for the function `:ns:func` to be successfully resolved:
257257
>
258258
> ```
259-
> The value is {horse :func}.
259+
> The value is {horse :ns:func}.
260260
> ```
261261
>
262262
> ```
263-
> .local $horse = {|horse| :func}
263+
> .local $horse = {|horse| :ns:func}
264264
> .match $horse
265265
> 1 {{The value is one.}}
266266
> * {{The value is not one.}}
@@ -297,26 +297,26 @@ Implementations MAY also provide implementation-defined _Message Function Error_
297297
> an object `{ name: 'Kat', id: 1234 }`,
298298
> 2. Provides for the variable reference `$field` to resolve to
299299
> a string `'address'`, and
300-
> 3. Uses a `:get` message function which requires its argument to be an object and
300+
> 3. Uses a `:ns:get` message function which requires its argument to be an object and
301301
> an option `field` to be provided with a string value.
302302
>
303303
> The exact type of _Message Function Error_ is determined by the _function handler_.
304304
>
305305
> ```
306-
> Hello, {horse :get field=name}!
306+
> Hello, {horse :ns:get field=name}!
307307
> ```
308308
>
309309
> ```
310-
> Hello, {$user :get}!
310+
> Hello, {$user :ns:get}!
311311
> ```
312312
>
313313
> ```
314-
> .local $id = {$user :get field=id}
315-
> {{Hello, {$id :get field=name}!}}
314+
> .local $id = {$user :ns:get field=id}
315+
> {{Hello, {$id :ns:get field=name}!}}
316316
> ```
317317
>
318318
> ```
319-
> Your {$field} is {$id :get field=$field}
319+
> Your {$field} is {$id :ns:get field=$field}
320320
> ```
321321
322322
### Bad Operand

spec/formatting.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Its _resolved value_ is defined by _literal resolution_.
213213
> ```
214214
> .local $aNumber = {1234 :number}
215215
> .local $aDate = {|2023-08-30| :datetime}
216-
> .local $aFoo = {|some foo| :foo}
216+
> .local $aFoo = {|some foo| :ns:foo}
217217
> {{You have {42 :number}}}
218218
> ```
219219
@@ -367,7 +367,7 @@ The order of _options_ MUST NOT be significant.
367367
368368
> For example, the following _message_ treats both both placeholders identically:
369369
> ```
370-
> {$x :function option1=foo option2=bar} {$x :function option2=bar option1=foo}
370+
> {$x :ns:func option1=foo option2=bar} {$x :ns:func option2=bar option1=foo}
371371
> ```
372372
373373
For each _option_:
@@ -439,9 +439,9 @@ The string representation of the _fallback value_ of an _expression_ depends on
439439
and then by U+007C VERTICAL LINE `|`.
440440
441441
> Examples:
442-
> In a context where `:func` fails to resolve,
443-
> `{42 :func}` resolves to a _fallback value_ with a string representation `|42|` and
444-
> `{|C:\\| :func}` resolves to a _fallback value_ with a string representation `|C:\\|`.
442+
> In a context where `:ns:func` fails to resolve,
443+
> `{42 :ns:func}` resolves to a _fallback value_ with a string representation `|42|` and
444+
> `{|C:\\| :ns:func}` resolves to a _fallback value_ with a string representation `|C:\\|`.
445445
446446
- _expression_ with _variable_ _operand_:
447447
the _fallback value_ representation of that _variable_,
@@ -452,24 +452,22 @@ The string representation of the _fallback value_ of an _expression_ depends on
452452
> both resolve to a _fallback value_ with a string representation `$var`
453453
> (even if `:number` fails to resolve).
454454
>
455-
> In a context where `:func` fails to resolve,
456-
> the _placeholder_ in `.local $var = {|val| :func} {{{$var}}}`
455+
> In a context where `:ns:func` fails to resolve,
456+
> the _placeholder_ in `.local $var = {|val| :ns:func} {{{$var}}}`
457457
> resolves to a _fallback value_ with a string representation `$var`.
458458
>
459-
> In a context where either `:now` or `:pretty` fails to resolve,
459+
> In a context where either `:ns:now` or `:ns:pretty` fails to resolve,
460460
> the _placeholder_ in
461461
> ```
462-
> .local $time = {:now format=iso8601}
463-
> {{{$time :pretty}}}
462+
> .local $time = {:ns:now format=iso8601}
463+
> {{{$time :ns:pretty}}}
464464
> ```
465465
> resolves to a _fallback value_ with a string representation `$time`.
466466
467467
- _function_ _expression_ with no _operand_:
468468
U+003A COLON `:` followed by the _function_ _identifier_
469469
470-
> Examples:
471-
> In a context where `:func` fails to resolve,
472-
> `{:func}` resolves to a _fallback value_ with a string representation `:func`.
470+
> Example:
473471
> In a context where `:ns:func` fails to resolve,
474472
> `{:ns:func}` resolves to a _fallback value_ with a string representation `:ns:func`.
475473

spec/syntax.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -406,14 +406,14 @@ There MUST be at least one _selector_ in a _matcher_.
406406
There MAY be any number of additional _selectors_.
407407

408408
> A _message_ with a single _selector_ that uses a custom _function_
409-
> `:hasCase` which is a _selector_ that allows the _message_ to choose a _pattern_
409+
> `:ns:hasCase` which is a _selector_ that allows the _message_ to choose a _pattern_
410410
> based on grammatical case:
411411
>
412412
> ```
413-
> .local $hasCase = {$userName :hasCase}
413+
> .local $hasCase = {$userName :ns:hasCase}
414414
> .match $hasCase
415-
> vocative {{Hello, {$userName :person case=vocative}!}}
416-
> accusative {{Please welcome {$userName :person case=accusative}!}}
415+
> vocative {{Hello, {$userName :ns:person case=vocative}!}}
416+
> accusative {{Please welcome {$userName :ns:person case=accusative}!}}
417417
> * {{Hello!}}
418418
> ```
419419
@@ -505,7 +505,7 @@ Additionally, an _input-declaration_ can contain a _variable-expression_.
505505
> Declarations:
506506
>
507507
> ```
508-
> .input {$x :function option=value}
508+
> .input {$x :ns:func option=value}
509509
> .local $y = {|This is an expression|}
510510
> ```
511511
>
@@ -514,8 +514,8 @@ Additionally, an _input-declaration_ can contain a _variable-expression_.
514514
> ```
515515
> This placeholder contains a literal expression: {|literal|}
516516
> This placeholder contains a variable expression: {$variable}
517-
> This placeholder references a function on a variable: {$variable :function with=options}
518-
> This placeholder contains a function expression with a variable-valued option: {:function option=$variable}
517+
> This placeholder references a function on a variable: {$variable :ns:func with=options}
518+
> This placeholder contains a function expression with a variable-valued option: {:ns:func option=$variable}
519519
> ```
520520
521521
### Operand
@@ -808,17 +808,20 @@ Examples:
808808
>```
809809
> This has a {$variable}
810810
>```
811-
> A function:
811+
>
812+
> A default function:
812813
> ```
813-
> This has a {:function}
814+
> This has an {42 :integer}
814815
> ```
815-
> An add-on function from the `icu` namespace:
816+
>
817+
> A function from the `ns` namespace:
816818
> ```
817-
> This has a {:icu:function}
819+
> This has a {:ns:function}
818820
> ```
819-
> An option and an add-on option:
821+
>
822+
> Options with and without a namespace:
820823
> ```
821-
> This has {:options option=value icu:option=add_on}
824+
> This has {:ns:function option=value ns:option=value}
822825
> ```
823826
824827
Support for _namespaces_ and their interpretation is implementation-defined

0 commit comments

Comments
 (0)