Hi Rob,
Am 13.05.2015 um 09:55 schrieb Rob Stapper:
Both do give the same, correct result: an empty sequence, but the first item unnecessarely triggers function: “local:f1#1” , while the second item doesn’t.
This is a subtle but important difference between the two ways of partially applying a function `f` to an argument expression `E`:
* `f(E, ?)` evaluates `E` *once* and creates a function item that supplies `f` with the result. This is preferable if evaluating `E` is expensive and the resulting function is called often.
* `function($x) { f(E, $x) }` evaluates `E` every time the created function item is called. This is better if there is at most one call.
the following query outputs "f1 f2 f2" from the `trace(...)` calls:
let $f1 := concat(trace('f1'), ?), $f2 := function($x) { concat(trace('f2'), $x) } for $f in ($f1, $f2) return ($f('a'), $f('b'))
Hope that helps, Leo