<div dir="ltr">Hi,<br><br>I have made a little experiment after reading Michael (Kay) blog posts about optimizations and recent James Fuller article.<br><br>I have a question quite specific to saxon still interesting in general.<br>
<br>Why in the following example even the function call is not skipped ?<br><br><br>XQuery is ::<br><br>declare variable $level := 3;<br><br>declare function local:debug($what){<br>&nbsp; if($level &gt;=4) then<br>&nbsp;&nbsp;&nbsp; &lt;debug&gt;{$what}&lt;/debug&gt;<br>
&nbsp; else ()<br>};<br><br>let $dosmthg := &lt;oki&gt;test trace&lt;/oki&gt;<br><br>return<br>(local:debug($dosmthg),$dosmthg)<br><br>When I run saxon with -explain we get <br><br>&lt;query&gt;<br>&nbsp; &lt;globalVariables&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;declareVariable name=&quot;level&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;literal value=&quot;3&quot; type=&quot;xs:integer&quot;/&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/declareVariable&gt;<br>&nbsp; &lt;/globalVariables&gt;<br>&nbsp; &lt;declareFunction name=&quot;local:debug&quot; tailRecursive=&quot;false&quot;&gt;<br>
&nbsp;&nbsp;&nbsp; &lt;literal value=&quot;()&quot;/&gt;<br>&nbsp; &lt;/declareFunction&gt;<br>&nbsp; &lt;body&gt;<br>&nbsp;&nbsp;&nbsp; &lt;let variable=&quot;dosmthg&quot; as=&quot;element(oki, {<a href="http://www.w3.org/2001/XMLSchema}untyped">http://www.w3.org/2001/XMLSchema}untyped</a>)&quot;&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;be&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;directElement name=&quot;oki&quot; validation=&quot;skip&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;valueOf&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;literal value=&quot;test trace&quot; type=&quot;xs:string&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/valueOf&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/directElement&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/be&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;return&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;sequence&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;functionCall name=&quot;local:debug&quot; tailCall=&quot;false&quot;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;variableReference name=&quot;dosmthg&quot;/&gt;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/functionCall&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;variableReference name=&quot;dosmthg&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/sequence&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/return&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/let&gt;<br>&nbsp; &lt;/body&gt;<br>&lt;/query&gt;<br><br>Cheers,<br>
RĂ©mi<br></div>