Hi WS,
Higher-order functions were added in XQuery 3.0 so that you can build
them dynamically (using closures) and pass them as parameters like any
other items.
I see little benefit in defining your function as a variable
declaration with an inline function expression vs. a static function
declaration such as
declare function local:id($x) {
$x
};
You can reference the former with $local:id and the latter with
local:id#1 to make them flow around as function items. You can call
the former with $local:id($x) and the latter with local:id($x). The
former has no name, the latter has a name (local:id).
When you need a function that dynamically depends on the value of a
variable at runtime, however, you will need to use inline function
expressions. Variables in scope will be added to the closure of the
created function item.
I hope it helps!
Kind regards,
Ghislain
Post by W.S. HagerHello,
What is the difference between a function declaration and a function
declare variable $local:id := function($x) { $x }
and why does it exist?
--
W.S. Hager
Lagua Web Solutions
http://lagua.nl
_______________________________________________
http://x-query.com/mailman/listinfo/talk
_______________________________________________
***@x-query.com
http://x-query.com/mailman/listinfo/talk