-
Notifications
You must be signed in to change notification settings - Fork 15
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
Function Coercion: Function Arities #705
Comments
I discovered FunctionCall-416, and I guess I got it wrong. I can partly answer my question by myself…
…as I see that 4.6.2.2 Evaluating Dynamic Function Calls is clear when it comes to the function arity:
Sorry for the noise, but I think some more examples would help, presenting cases in which the function coercion is actually applied, besides from built-in functions. |
Coercion happens when you supply a value V for a variable or function argument requiring a type T. So if you supply a function of arity 1 where a function of arity 2 is required, coercion happens. It doesn't happen on the dynamic function call itself. |
Thanks for helping me think. – It took me longer than I hoped to formulate sensible examples, until I realized that the proposed extensions in #516 can simply be written as user-defined functions. Another example would be this: let $upper-case-when := function(
$string as xs:string,
$test as function(item()) as item()
) as xs:string {
if ($test($string)) then upper-case($string) else $string
}
return $upper-case-when('always', true#0) Maybe there are better examples, suggestions are welcome. I can imagine it’s tricky to grasp though, so I’ll keep this issue open until we’ve added one or more examples in the text, for example to the existing note (“This mechanism makes it easier to design versatile and extensible higher-order functions. […]”). |
I left this open because I thought that more examples would be helpful for the coercion rules. |
The CG agreed to close this issue without action meeting 59. |
In 4.6.4 Function Coercion, a rule was added to support functions with an arity lower than the expected one:
If I got it right, this is the resulting 4.0 behavior:
Spoiler: I probably got it wrong, see the next comment.
Maybe some more examples should be added in the corresponding sections that refer to function coercion.
The new rule is powerful and allows for greater flexibility (see #516 and other issues), but the behavior may also be unexpected. We should probably document that:
The text was updated successfully, but these errors were encountered: