<div dir="ltr">Hi again,<br><br>In the same spirit, this is not at all optimized.<br>Maybe I need Saxon SA ?<br><br><br>declare variable $level as xs:integer := 3 ;<br><br>declare function local:debug($l as xs:integer,$what){<br>
if($l >=4) then<br> <debug>{$what}</debug><br> else ()<br>};<br><br>let $dosmthg := <oki>test trace</oki><br><br>return<br>(local:debug($level,$dosmthg),$dosmthg)<br><br><br>Rémi<br><br><div class="gmail_quote">
On Fri, Oct 3, 2008 at 3:17 PM, Rémi Dewitte <span dir="ltr"><<a href="mailto:remi@gide.net">remi@gide.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<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> if($level >=4) then<br> <debug>{$what}</debug><br>
else ()<br>};<br><br>let $dosmthg := <oki>test trace</oki><br><br>return<br>(local:debug($dosmthg),$dosmthg)<br><br>When I run saxon with -explain we get <br><br><query><br> <globalVariables><br>
<declareVariable name="level"><br> <literal value="3" type="xs:integer"/><br> </declareVariable><br> </globalVariables><br> <declareFunction name="local:debug" tailRecursive="false"><br>
<literal value="()"/><br> </declareFunction><br> <body><br> <let variable="dosmthg" as="element(oki, {<a href="http://www.w3.org/2001/XMLSchema%7Duntyped" target="_blank">http://www.w3.org/2001/XMLSchema}untyped</a>)"><br>
<be><br> <directElement name="oki" validation="skip"><br> <valueOf><br> <literal value="test trace" type="xs:string"/><br> </valueOf><br>
</directElement><br> </be><br> <return><br> <sequence><br> <functionCall name="local:debug" tailCall="false"><br> <variableReference name="dosmthg"/><br>
</functionCall><br> <variableReference name="dosmthg"/><br> </sequence><br> </return><br> </let><br> </body><br></query><br><br>Cheers,<br>
Rémi<br></div>
</blockquote></div><br></div>