This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
define function local:foo($bar, $baz=fn:current-date-time()) { ... } ; instead of define function local:foo($bar) { local:foo($bar, fn:current-date-time()) } ; define function local:foo($bar, $baz) { ... } ;
I think this is an interesting future direction, since it will also allow users to safely define functions that take the context item as an implicit argument: define function local:findIDs($node as node() := .) { $node//@id }; This kind of default argument is evaluated in the calling context, rather than the function's context. That said, this is almost certainly a feature that should be considered for XQuery 1.2 rather than XQuery 1.1.
Polymorphism is already listed as a potential feature for future versions, as are generics: Bug 9062 This is related to polymorphism, but you ask for defaults as well. I'd like to move this to future versions.
Renamed the requirement to emphasize its relatively modest ambitions; as described, this is simply a convenient way of defining a family of functions with the same name and different arity using fewer lines of code than currently needed.
There's a little more to this feature request. Default arguments would be evaluated in the static and dynamic context of the caller, which would allow the definition of functions which took a default context item, for instance.
The static environment of the caller? So $x:var accesses different variables depending on the namespace binding of x? Surely not.
Interesting point - this clearly needs more thought. I do think it's reasonable to have a default argument of fn:default-collation() however, which is what I was thinking of when I said it should use the static context of the caller.
Assigning to future requirements per Working Group decision (https://lists.w3.org/Archives/Member/w3c-xsl-query/2012Oct/0087.html).