<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22936</bug_id>
          
          <creation_ts>2013-08-13 10:35:42 +0000</creation_ts>
          <short_desc>[XSLT 3.0] Streamability : dynamic calls to context dependent functions</short_desc>
          <delta_ts>2014-05-15 14:00:19 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XPath / XQuery / XSLT</product>
          <component>XSLT 3.0</component>
          <version>Working drafts</version>
          <rep_platform>PC</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Michael Kay">mike</reporter>
          <assigned_to name="Michael Kay">mike</assigned_to>
          
          
          <qa_contact name="Mailing list for public feedback on specs from XSL and XML Query WGs">public-qt-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>91976</commentid>
    <comment_count>0</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-08-13 10:35:42 +0000</bug_when>
    <thetext>We say that a NamedFunctionRef is motionless.

Similarly we have no special rules for function-lookup().

However, in both cases these constructs are not as innocent as they seem, because they capture the dynamic context at the point they are evaluated, and use that dynamic context later when the resulting function is called.

For example:

&lt;xsl:variable name=&quot;saved-current&quot; select=&quot;current#0&quot;/&gt;
&lt;xsl:for-each select=&quot;transaction&quot;&gt;
  &lt;xsl:if test=&quot;value = $saved-current()/value&quot;&gt;
    ...
  &lt;/xsl:if&gt;
&lt;/xsl:for-each&gt;

is clearly not streamable.

So:

(a) A NamedFunctionRef should be free-ranging if the function is dependent on (relevant parts of?) the dynamic context

(b) function-lookup() should always be free-ranging (because we have no way of knowing what it might do).

(c) Partial function application could also be dangerous in the same way if we had any focus-dependent functions with two or more arguments. Fortunately we don&apos;t, though it seems a little odd to assume that.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93739</commentid>
    <comment_count>1</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-09-24 16:53:23 +0000</bug_when>
    <thetext>Noted that partial function application is currently already free-ranging - we&apos;re not sure why. We think this restriction should be removed.

For the other cases we agree that the use of focius-dependent functions should be restricted. For function-lookup() we think this should be a dynamic error so that we don&apos;t ban all uses of function-lookup(), most of which will be perfectly innocent.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93748</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-09-24 22:00:10 +0000</bug_when>
    <thetext>I&apos;m re-opening this in respect of the rules for function-lookup(). We suggested that this should return a dynamic error if (when streaming?) the function actually selected is a focus-dependent function. However, it&apos;s not clear what the actual circumstances for this error should be. In addition, raising such an error would require modification to the XPath specification of function-lookup(), which we should avoid if possible.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93807</commentid>
    <comment_count>3</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-09-25 15:38:37 +0000</bug_when>
    <thetext>We looked again at the function-lookup case and it starts to make more sense.

Given $f := function-lookup(&quot;fn:lang&quot;, 1) followed by $f(&quot;en&quot;), this is supposed to test the language of the node that was the context item at the time function-lookup was called. If this was a node in a streamed document, we can&apos;t safe a reference to it in the function closure. So we should define that in this case, in the closure we set the context item to &quot;absent&quot;, which leads to a dynamic error if and when $f(&quot;en&quot;) is actually called.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>93858</commentid>
    <comment_count>4</comment_count>
    <who name="Michael Kay">mike</who>
    <bug_when>2013-09-26 07:07:55 +0000</bug_when>
    <thetext>Spec updated (section id = #function-lookup)</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>