-
-
Notifications
You must be signed in to change notification settings - Fork 35
Description
There are many environments where it is important to minimize* the possibility of runtime errors when formatting messages. I think we can do that for an important class of Selectors and Functions if we provide for more information in the registry. The following is still pretty rough, but it is what I'm trying to get at.
A Selector is well-behaved when all of the following conditions are met:
- It declares a domain of variant keys, (eg "high", "medium", "low"; or integers; or any-string) in the registry.
- For any set of modifiers it will return true for at least one element in that domain, and will return true or false for all others (without error).
- It will always return true for *, with any set of modifiers.
A Function is well-behaved when all of the following conditions are met:
- It declares a domain of variant keys (eg "high", "medium", "low"; or integers; or any-string) in the registry.
- For any set of modifiers it will return a string for each element in that domain. (without error)
A message format is well-behaved when all of the following conditions are met:
- It is syntactically correct.
- All of its Selectors and Functions are well-behaved.
Inputs to a message format are complete when there is a value for each one of them that is used by a Selector (or Function) in the message, and that value is in the domain of that Selector (or Function).
Take the following message:
match {$personCount :number} {$venue :string}
when 1 * {There is a person at {$venue}}
when other * {There are {$personCount} people at {$venue}}
-
The following inputs are complete
$personCount == 1
$venue == "Paris" -
The following inputs are not complete ($venue has no value)
$personCount == 1 -
The following inputs are not complete ($personCount is not a number)
$personCount == "fish"
$venue == "Paris"
Well-behaved messages will not produce errors when their inputs are complete. This does not, of course, include extraordinary conditions such as out-of-memory.
Implementations of all standard registered Selectors and Functions must be well-behaved. Custom Selectors and Functions might not be.