Hi Rob,
this behaves as expected. The default for parameter $exec only applies, when you omit the argument, as in
this behaves as expected. The default for parameter $exec only applies, when you omit the argument, as in
local:test()
But in your example, the function item is the empty sequence, so you are effectively doing
()("a", "b")
which by definition results in the empty sequence:
Best regards
Gunther
Gesendet: Samstag, 14. Februar 2026 um 09:57
Von: "Rob Stapper via BaseX-Talk" <[email protected]>
An: "[email protected]" <[email protected]>
Betreff: [basex-talk] function as default parameter
Good morning,
I came across some unexpected behaviour when using a function as a default functionparameter:
declare function local:test
( $exec as function(*)? := fn( $a, $b) { $a => trace("test1: ") }
)
{ $exec( "a", "b")
} ;
local:test(())
( $exec as function(*)? := fn( $a, $b) { $a => trace("test1: ") }
)
{ $exec( "a", "b")
} ;
local:test(())
I would expect a trace- and a execution result, but I got nothing. Are my expectations wrong or could it be a bug?
PS code snipped added as test.xqm
PS The optimized query shows an empty value.
mvgr. Rob Stapper

