Skip to content

Commit 56fcc84

Browse files
catamorphismgibson042eemeliaphillipsmacchiati
authored
Add note to "Function Resolution" section about function argument and result types (#686)
* Add note to "Function Resolution" section about function argument and result types * Rephrase the 'result of a function call' sentence * Rewrite the description of "composability" Avoid using the word "interconvertible" Include example of composability Include example for how the function interface would be defined in a typed implementation language Add note about multiple interpretations of composition that requests feedback * Add specific text on selector functions * Fix .local syntax in example * Address various review comments * Update spec/formatting.md Co-authored-by: Richard Gibson <[email protected]> * Update spec/formatting.md Co-authored-by: Eemeli Aro <[email protected]> * Add the words "a representation of" to allow implementations... ...to bundle their results with a "parsed" version of their input * Update spec/formatting.md Co-authored-by: Eemeli Aro <[email protected]> * Avoid use of 'input'/'output' * Update spec/formatting.md Co-authored-by: Addison Phillips <[email protected]> * Update spec/formatting.md Co-authored-by: Addison Phillips <[email protected]> * Update spec/formatting.md Co-authored-by: Mark Davis <[email protected]> * Update spec/formatting.md Co-authored-by: Mark Davis <[email protected]> * Update spec/formatting.md Co-authored-by: Mark Davis <[email protected]> * Update spec/formatting.md Co-authored-by: Mark Davis <[email protected]> --------- Co-authored-by: Richard Gibson <[email protected]> Co-authored-by: Eemeli Aro <[email protected]> Co-authored-by: Addison Phillips <[email protected]> Co-authored-by: Mark Davis <[email protected]>
1 parent d2b5fd8 commit 56fcc84

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

spec/formatting.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,75 @@ the following steps are taken:
222222
223223
The form that resolved _operand_ and _option_ values take is implementation-defined.
224224
225+
A _declaration_ binds the resolved value of an _expression_
226+
to a _variable_.
227+
Thus, the result of one _function_ is potentially the _operand_
228+
of another _function_,
229+
or the value of one of the _options_ for another function.
230+
For example, in
231+
```
232+
.input {$n :number minIntegerDigits=3}
233+
.local $n1 = {$n :number maxFractionDigits=3}
234+
```
235+
the value bound to `$n` is the
236+
resolved value used as the _operand_
237+
of the `:number` _function_
238+
when resolving the value of the _variable_ `$n1`.
239+
240+
Implementations that provide a means for defining custom functions
241+
SHOULD provide a means for function implementations
242+
to return values that contain enough information
243+
(e.g. a representation of
244+
the resolved _operand_ and _option_ values
245+
that the function was called with)
246+
to be used as arguments to subsequent calls
247+
to the function implementations.
248+
For example, an implementation might define an interface that allows custom function implementation.
249+
Such an interface SHOULD define an implementation-specific
250+
argument type `T` and return type `U`
251+
for implementations of functions
252+
such that `U` can be coerced to `T`.
253+
Implementations of a _function_ SHOULD emit an
254+
_Invalid Expression_ error for _operands_ whose resolved value
255+
or type is not supported.
256+
257+
> [!NOTE]
258+
> The behavior of the previous example is
259+
> currently implementation-dependent. Supposing that
260+
> the external input variable `n` is bound to the string `"1"`,
261+
> and that the implementation formats to a string,
262+
> the formatted result of the following message:
263+
>
264+
> ```
265+
> .input {$n :number minIntegerDigits=3}
266+
> .local $n1 = {$n :number maxFractionDigits=3}
267+
> {{$n1}}
268+
> ```
269+
>
270+
> is currently implementation-dependent.
271+
> Depending on whether the options are preserved
272+
> between the resolution of the first `:number` _annotation_
273+
> and the resolution of the second `:number` _annotation_,
274+
> a conformant implementation
275+
> could produce either "001.000" or "1.000"
276+
>
277+
> Each function **specification** MAY have
278+
> its own rules to preserve some options in the returned structure
279+
> and discard others.
280+
> In instances where a function specification does not determine whether an option is preserved or discarded,
281+
> each function **implementation** of that specification MAY have
282+
> its own rules to preserve some options in the returned structure
283+
> and discard others.
284+
>
285+
>
286+
> [!NOTE]
287+
> During the Technical Preview,
288+
> feedback on how the registry describes
289+
> the flow of _resolved values_ and _options_
290+
> from one _function_ to another,
291+
> and on what requirements this specification should impose,
292+
> is highly desired.
293+
225294
An implementation MAY pass additional arguments to the function,
226295
as long as reasonable precautions are taken to keep the function interface
227296
simple and minimal, and avoid introducing potential security vulnerabilities.

0 commit comments

Comments
 (0)