-
-
Notifications
You must be signed in to change notification settings - Fork 36
Implementing namespacing #524
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 all commits
d850cf4
1cf7f39
30cdac6
d875dd3
a75908a
7f099a2
bcff52e
7e73ab7
732ab83
d69a927
1dc97bf
85d7ead
c3ad9d9
9e40a9c
233c217
9830785
341717c
290a7c4
2c471a5
4507a4e
6b15f10
cccb7ad
ef83110
e9fb373
17d714e
714b4fe
0c50ab7
3625ac4
94dfbd4
4692f72
3adb4aa
0b7042b
a4920fa
d3e0e58
938d7d5
fd62645
60a1740
023b5a8
1e9e644
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 | ||
---|---|---|---|---|
|
@@ -197,17 +197,28 @@ the following steps are taken: | |||
|
||||
1. If the _expression_ includes an _operand_, resolve its value. | ||||
If this fails, use a _fallback value_ for the _expression_. | ||||
2. Based on the _function_ starting sigil and _name_, | ||||
find the appropriate function implementation from the _function registry_. | ||||
If the registry does not define an implementation for this _name_, | ||||
2. Resolve the _identifier_ of the _function_ and, based on the starting sigil, | ||||
find the appropriate function implementation to call. | ||||
If the implementation cannot find the function, | ||||
or if the _identifier_ includes a _namespace_ that the implementation does not support, | ||||
emit an Unknown Function error | ||||
and use a _fallback value_ for the _expression_. | ||||
3. Resolve the _option_ values to a mapping of string identifiers to values. | ||||
|
||||
Implementations are not required to implement _namespaces_ or installable | ||||
_function registries_. | ||||
|
||||
3. Resolve the _options_ to a mapping of string identifiers to values. | ||||
If _options_ is missing, the mapping will be empty. | ||||
For each _option_: | ||||
- If its right-hand side successfully resolves to a value, | ||||
bind the _name_ of the _option_ to the resolved value in the mapping. | ||||
- Otherwise, do not bind the _name_ of the _option_ to any value in the mapping. | ||||
4. Call the function implementation with the following arguments: | ||||
- Resolve the _identifier_ of the _option_. | ||||
- If the _option_'s _identifier_ already exists in the resolved mapping of _options_, | ||||
emit a Duplicate Option Name error. | ||||
- If the _option_'s right-hand side successfully resolves to a value, | ||||
bind the _identifier_ of the _option_ to the resolved value in the mapping. | ||||
- Otherwise, bind the _identifier_ of the _option_ to an unresolved value in the mapping. | ||||
(Note that an Unresolved Variable error will have been emitted.) | ||||
4. Remove from the resolved mapping of _options_ any binding for which the value is an unresolved value. | ||||
stasm marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
5. Call the function implementation with the following arguments: | ||||
aphillips marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
- The current _locale_. | ||||
- The resolved mapping of _options_. | ||||
|
@@ -219,15 +230,20 @@ the following steps are taken: | |||
as long as reasonable precautions are taken to keep the function interface | ||||
simple and minimal, and avoid introducing potential security vulnerabilities. | ||||
|
||||
As implementations MAY allow custom functions to be defined by users, | ||||
their access to the _formatting context_ SHOULD be minimal and read-only, | ||||
and their execution time SHOULD be limited. | ||||
An implementation MAY define its own functions. | ||||
An implementation MAY allow custom functions to be defined by users. | ||||
|
||||
Function access to the _formatting context_ MUST be minimal and read-only, | ||||
and execution time SHOULD be limited. | ||||
|
||||
Implementation-defined _functions_ SHOULD use an implementation-defined _namespace_. | ||||
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. Does "implementation-defined" include the implementations of the default registry's functions? Or do you mean other functions built into the implementation, but not present in the default registry? 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'm thinking of going back to the design document and adding some use cases to illustrate these. In this case, I mean "non-default registry functions". I will add text to clarify. Suppose you're Mihai and you're creating the ICU4J implementation. The Mihai might want to expose Suppose he then goes on to implement Suppose Mihai goes on to implement an SPI for custom functions. Suppose I write my own date formatter. It doesn't replace the one in
Suppose you're a tool implementer working with messages written for Mihai's implementation with my add-on. When you see a namespace prefix, that tells you that the function or the option is non-standard. The prefix might tell you where to look for the add-on registry or at least be something that you can key locally. Tool consumption is a key reason for namespacing. 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. Adding these use-cases in form of such user journeys sounds great. I'll be happy to contribute. Open a new PR? 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. Might be best to add a subsection to "Function Resolution" that collects these directions about what's possible and recommended for implementations and users to do with functions?
Suggested change
|
||||
|
||||
5. If the call succeeds, | ||||
resolve the value of the _expression_ as the result of that function call. | ||||
If the call fails or does not return a valid value, | ||||
emit a Resolution error and use a _fallback value_ for the _expression_. | ||||
|
||||
|
||||
### Fallback Resolution | ||||
|
||||
A **_fallback value_** is the resolved value emitted when an _expression_ cannot be resolved. | ||||
|
@@ -255,13 +271,13 @@ The _fallback value_ depends on the contents of the _expression_: | |||
> Example: `$user` | ||||
|
||||
- _expression_ with no _operand_: | ||||
the _function_ starting sigil followed by its _name_ | ||||
the _function_ starting sigil followed by its _identifier_ | ||||
|
||||
> Examples: `:platform`, `+tag`, `-tag` | ||||
|
||||
- Otherwise: The U+FFFD REPLACEMENT CHARACTER `�` character | ||||
|
||||
_Option_ names and values are not included in the _fallback value_. | ||||
_Option_ identifiers and values are not included in the _fallback value_. | ||||
|
||||
When an error occurs in an _expression_ with a _variable_ _operand_ | ||||
and the _variable_ refers to a local _declaration_, | ||||
|
@@ -817,7 +833,7 @@ These are divided into the following categories: | |||
> }} | ||||
> ``` | ||||
|
||||
- A **Duplicate Option Name error** occurs when the same _name_ | ||||
- A **Duplicate Option Name error** occurs when the same _identifier_ | ||||
appears on the left-hand side | ||||
of more than one _option_ in the same _expression_. | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems out of place. If we do want to mention something like this, it should not be here, in the middle of an algorithmic sequence of steps.