- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 35
 
Add Resolved Values and Function Handler sections to formatting #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
a99f6cb
              3d31e10
              512c14f
              17a9830
              94098ca
              ecb071c
              28cb811
              050dd9b
              6e93724
              55caa12
              2b48b88
              1646e68
              df21df3
              ec3e484
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -85,10 +85,16 @@ At a minimum, it includes: | |||||
| 
     | 
||||||
| Implementations MAY include additional fields in their _formatting context_. | ||||||
| 
     | 
||||||
| ## Expression and Markup Resolution | ||||||
| ## Resolved Values | ||||||
| 
     | 
||||||
| _Expressions_ are used in _declarations_, _selectors_, and _patterns_. | ||||||
| _Markup_ is only used in _patterns_. | ||||||
| This specification allows for the same value to be used for: | ||||||
| - formatting in a _placeholder_, | ||||||
                
       | 
||||||
| - selection in a _selector_ _expression_, | ||||||
| - as the _operand_ of another _expression_ (including _local declarations_), or | ||||||
| - as an _option_ value in another _expression_, | ||||||
                
      
                  eemeli marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||||||
| 
     | 
||||||
| To support this, the _**resolved value**_ of each _expression_ | ||||||
| is an implementation-dependent value that supports some or all of the above use cases. | ||||||
| 
     | 
||||||
| In a _declaration_, the resolved value of the _expression_ is bound to a _variable_, | ||||||
| which is available for use by later _expressions_. | ||||||
| 
        
          
        
         | 
    @@ -106,16 +112,46 @@ In a _pattern_, the resolved value of an _expression_ or _markup_ is used in its | |||||
| The form that resolved values take is implementation-dependent, | ||||||
| and different implementations MAY choose to perform different levels of resolution. | ||||||
| 
     | 
||||||
| > For example, the resolved value of the _expression_ `{|0.40| :number style=percent}` | ||||||
| > could be an object such as | ||||||
| > While this specification does not require it, | ||||||
| > a _resolved value_ could be implemented by requiring each function implementation to | ||||||
| > return a value matching the following interface: | ||||||
                
      
                  eemeli marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||||||
| > | ||||||
| > ```ts | ||||||
| > interface MessageValue { | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Overall the direction seems OK. 
 So it feels over-specified.  | 
||||||
| > formatToString(): string | ||||||
| > formatToX(): X // where X is an implementation-defined type | ||||||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I may have missed some discussions about this, but why wouldn't we want to be more specific here about the parts? 
        Suggested change
       
    
 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As this is a non-normative example and we've not reached consensus on formatted parts, I'd rather not introduce them here implicitly and somewhat out of context, when the key aspect of the   | 
||||||
| > getValue(): unknown | ||||||
| > resolvedOptions(): { [key: string]: MessageValue } | ||||||
| > selectKeys(keys: string[]): string[] | ||||||
| > } | ||||||
| > ``` | ||||||
| > { value: Number('0.40'), | ||||||
| > formatter: NumberFormat(locale, { style: 'percent' }) } | ||||||
| > ``` | ||||||
| > | ||||||
| > Alternatively, it could be an instance of an ICU4J `FormattedNumber`, | ||||||
| > or some other locally appropriate value. | ||||||
| > With this approach: | ||||||
| > - An _expression_ could be used as a _placeholder_ if | ||||||
| > calling the `formatToString()` or `formatToX()` method of its _resolved value_ | ||||||
| > did not emit an error. | ||||||
| > - An _expression_ could be used as a _selector_ _expression_ if | ||||||
| > calling the `selectKeys(keys)` method of its _resolved value_ | ||||||
| > did not throw an error. | ||||||
                
      
                  eemeli marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||||||
| > - Using a _variable reference_, the resolved value of an _expression_ | ||||||
| > could be used as an _operand_ or _option_ value if | ||||||
| > calling the `getValue()` method of its _resolved value_ did not throw an error. | ||||||
                
      
                  eemeli marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||||||
| > In this use case, the `resolvedOptions()` method could also | ||||||
| > provide a set of option values that could be taken into account by the called function. | ||||||
| > | ||||||
| > Extensions of the base `MessageValue` interface could be provided for different data types, | ||||||
| > such as numbers or strings, | ||||||
| > for which the `unknown` return type of `getValue()` and | ||||||
| > the generic `MessageValue` type used in `resolvedOptions()` | ||||||
| > could be narrowed appropriately. | ||||||
| > An implementation could also allow `MessageValue` values to be passed in as input variables, | ||||||
| > or automatically wrap each variable as a `MessageValue` to provide a uniform interface | ||||||
                
      
                  catamorphism marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||||||
| > for custom functions. | ||||||
| 
     | 
||||||
| ## Expression and Markup Resolution | ||||||
| 
     | 
||||||
| _Expressions_ are used in _declarations_, _selectors_, and _patterns_. | ||||||
| _Markup_ is only used in _patterns_. | ||||||
| 
     | 
||||||
| Depending on the presence or absence of a _variable_ or _literal_ operand | ||||||
| and a _function_, _private-use annotation_, or _reserved annotation_, | ||||||
| 
          
            
          
           | 
    ||||||
Uh oh!
There was an error while loading. Please reload this page.