Dear BaseX people,
I observe a behaviour which appears to me not desirable, although it is, 
strictly speaking, correct. Please consider this code:
    let $fnCopy := function($term) {trace('yes', 'within fnCopy: ')}        let 
$_DEBUG := trace('before call fnCopy')    let $result := $fnCopy('yogi')    (: 
let $_DEBUG := if ($result eq 'NEVER') then error() else () :)    let $_DEBUG 
:= trace('after call fnCopy')        return ()
As long as the commented out clause is not activated, the function is *not* 
executed. It is strictly speaking correct behaviour: the processor may optimize 
and skip the call of $fnCopy, as it does not contribute to the value of the 
containing FLWOR expression.
However, when using functions with side-effects (as file:write()), it is of 
course necessary to be sure that the call is executed. Contrary to other 
processors, according to my experience BaseX has never skipped let clauses for 
reasons of optimization, and in many years of usage I have again and again 
highly appreciated this behaviour.
The skipping behaviour is new to me. Is it so that BaseX has changed its policy 
concerning let clauses not contributing to the FLWOR result? It would be very 
important to know, because the execution of functions with side effects is 
everyday practice.
Kind regards,Hans-Jürgen

Reply via email to